aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/go-plugin/grpc_client.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-plugin/grpc_client.go')
-rw-r--r--vendor/github.com/hashicorp/go-plugin/grpc_client.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/vendor/github.com/hashicorp/go-plugin/grpc_client.go b/vendor/github.com/hashicorp/go-plugin/grpc_client.go
index 44294d0..294518e 100644
--- a/vendor/github.com/hashicorp/go-plugin/grpc_client.go
+++ b/vendor/github.com/hashicorp/go-plugin/grpc_client.go
@@ -6,6 +6,7 @@ import (
6 "net" 6 "net"
7 "time" 7 "time"
8 8
9 "github.com/hashicorp/go-plugin/internal/plugin"
9 "golang.org/x/net/context" 10 "golang.org/x/net/context"
10 "google.golang.org/grpc" 11 "google.golang.org/grpc"
11 "google.golang.org/grpc/credentials" 12 "google.golang.org/grpc/credentials"
@@ -16,12 +17,9 @@ func dialGRPCConn(tls *tls.Config, dialer func(string, time.Duration) (net.Conn,
16 // Build dialing options. 17 // Build dialing options.
17 opts := make([]grpc.DialOption, 0, 5) 18 opts := make([]grpc.DialOption, 0, 5)
18 19
19 // We use a custom dialer so that we can connect over unix domain sockets 20 // We use a custom dialer so that we can connect over unix domain sockets.
20 opts = append(opts, grpc.WithDialer(dialer)) 21 opts = append(opts, grpc.WithDialer(dialer))
21 22
22 // go-plugin expects to block the connection
23 opts = append(opts, grpc.WithBlock())
24
25 // Fail right away 23 // Fail right away
26 opts = append(opts, grpc.FailOnNonTempDialError(true)) 24 opts = append(opts, grpc.FailOnNonTempDialError(true))
27 25
@@ -58,12 +56,15 @@ func newGRPCClient(doneCtx context.Context, c *Client) (*GRPCClient, error) {
58 go broker.Run() 56 go broker.Run()
59 go brokerGRPCClient.StartStream() 57 go brokerGRPCClient.StartStream()
60 58
61 return &GRPCClient{ 59 cl := &GRPCClient{
62 Conn: conn, 60 Conn: conn,
63 Plugins: c.config.Plugins, 61 Plugins: c.config.Plugins,
64 doneCtx: doneCtx, 62 doneCtx: doneCtx,
65 broker: broker, 63 broker: broker,
66 }, nil 64 controller: plugin.NewGRPCControllerClient(conn),
65 }
66
67 return cl, nil
67} 68}
68 69
69// GRPCClient connects to a GRPCServer over gRPC to dispense plugin types. 70// GRPCClient connects to a GRPCServer over gRPC to dispense plugin types.
@@ -73,11 +74,14 @@ type GRPCClient struct {
73 74
74 doneCtx context.Context 75 doneCtx context.Context
75 broker *GRPCBroker 76 broker *GRPCBroker
77
78 controller plugin.GRPCControllerClient
76} 79}
77 80
78// ClientProtocol impl. 81// ClientProtocol impl.
79func (c *GRPCClient) Close() error { 82func (c *GRPCClient) Close() error {
80 c.broker.Close() 83 c.broker.Close()
84 c.controller.Shutdown(c.doneCtx, &plugin.Empty{})
81 return c.Conn.Close() 85 return c.Conn.Close()
82} 86}
83 87