diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/go-plugin/grpc_broker.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/go-plugin/grpc_broker.go')
-rw-r--r-- | vendor/github.com/hashicorp/go-plugin/grpc_broker.go | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/vendor/github.com/hashicorp/go-plugin/grpc_broker.go b/vendor/github.com/hashicorp/go-plugin/grpc_broker.go index 49fd21c..daf142d 100644 --- a/vendor/github.com/hashicorp/go-plugin/grpc_broker.go +++ b/vendor/github.com/hashicorp/go-plugin/grpc_broker.go | |||
@@ -11,6 +11,8 @@ import ( | |||
11 | "sync/atomic" | 11 | "sync/atomic" |
12 | "time" | 12 | "time" |
13 | 13 | ||
14 | "github.com/hashicorp/go-plugin/internal/plugin" | ||
15 | |||
14 | "github.com/oklog/run" | 16 | "github.com/oklog/run" |
15 | "google.golang.org/grpc" | 17 | "google.golang.org/grpc" |
16 | "google.golang.org/grpc/credentials" | 18 | "google.golang.org/grpc/credentials" |
@@ -19,14 +21,14 @@ import ( | |||
19 | // streamer interface is used in the broker to send/receive connection | 21 | // streamer interface is used in the broker to send/receive connection |
20 | // information. | 22 | // information. |
21 | type streamer interface { | 23 | type streamer interface { |
22 | Send(*ConnInfo) error | 24 | Send(*plugin.ConnInfo) error |
23 | Recv() (*ConnInfo, error) | 25 | Recv() (*plugin.ConnInfo, error) |
24 | Close() | 26 | Close() |
25 | } | 27 | } |
26 | 28 | ||
27 | // sendErr is used to pass errors back during a send. | 29 | // sendErr is used to pass errors back during a send. |
28 | type sendErr struct { | 30 | type sendErr struct { |
29 | i *ConnInfo | 31 | i *plugin.ConnInfo |
30 | ch chan error | 32 | ch chan error |
31 | } | 33 | } |
32 | 34 | ||
@@ -38,7 +40,7 @@ type gRPCBrokerServer struct { | |||
38 | send chan *sendErr | 40 | send chan *sendErr |
39 | 41 | ||
40 | // recv is used to receive connection info from the gRPC stream. | 42 | // recv is used to receive connection info from the gRPC stream. |
41 | recv chan *ConnInfo | 43 | recv chan *plugin.ConnInfo |
42 | 44 | ||
43 | // quit closes down the stream. | 45 | // quit closes down the stream. |
44 | quit chan struct{} | 46 | quit chan struct{} |
@@ -50,7 +52,7 @@ type gRPCBrokerServer struct { | |||
50 | func newGRPCBrokerServer() *gRPCBrokerServer { | 52 | func newGRPCBrokerServer() *gRPCBrokerServer { |
51 | return &gRPCBrokerServer{ | 53 | return &gRPCBrokerServer{ |
52 | send: make(chan *sendErr), | 54 | send: make(chan *sendErr), |
53 | recv: make(chan *ConnInfo), | 55 | recv: make(chan *plugin.ConnInfo), |
54 | quit: make(chan struct{}), | 56 | quit: make(chan struct{}), |
55 | } | 57 | } |
56 | } | 58 | } |
@@ -58,7 +60,7 @@ func newGRPCBrokerServer() *gRPCBrokerServer { | |||
58 | // StartStream implements the GRPCBrokerServer interface and will block until | 60 | // StartStream implements the GRPCBrokerServer interface and will block until |
59 | // the quit channel is closed or the context reports Done. The stream will pass | 61 | // the quit channel is closed or the context reports Done. The stream will pass |
60 | // connection information to/from the client. | 62 | // connection information to/from the client. |
61 | func (s *gRPCBrokerServer) StartStream(stream GRPCBroker_StartStreamServer) error { | 63 | func (s *gRPCBrokerServer) StartStream(stream plugin.GRPCBroker_StartStreamServer) error { |
62 | doneCh := stream.Context().Done() | 64 | doneCh := stream.Context().Done() |
63 | defer s.Close() | 65 | defer s.Close() |
64 | 66 | ||
@@ -97,7 +99,7 @@ func (s *gRPCBrokerServer) StartStream(stream GRPCBroker_StartStreamServer) erro | |||
97 | 99 | ||
98 | // Send is used by the GRPCBroker to pass connection information into the stream | 100 | // Send is used by the GRPCBroker to pass connection information into the stream |
99 | // to the client. | 101 | // to the client. |
100 | func (s *gRPCBrokerServer) Send(i *ConnInfo) error { | 102 | func (s *gRPCBrokerServer) Send(i *plugin.ConnInfo) error { |
101 | ch := make(chan error) | 103 | ch := make(chan error) |
102 | defer close(ch) | 104 | defer close(ch) |
103 | 105 | ||
@@ -115,7 +117,7 @@ func (s *gRPCBrokerServer) Send(i *ConnInfo) error { | |||
115 | 117 | ||
116 | // Recv is used by the GRPCBroker to pass connection information that has been | 118 | // Recv is used by the GRPCBroker to pass connection information that has been |
117 | // sent from the client from the stream to the broker. | 119 | // sent from the client from the stream to the broker. |
118 | func (s *gRPCBrokerServer) Recv() (*ConnInfo, error) { | 120 | func (s *gRPCBrokerServer) Recv() (*plugin.ConnInfo, error) { |
119 | select { | 121 | select { |
120 | case <-s.quit: | 122 | case <-s.quit: |
121 | return nil, errors.New("broker closed") | 123 | return nil, errors.New("broker closed") |
@@ -136,13 +138,13 @@ func (s *gRPCBrokerServer) Close() { | |||
136 | // streamer interfaces. | 138 | // streamer interfaces. |
137 | type gRPCBrokerClientImpl struct { | 139 | type gRPCBrokerClientImpl struct { |
138 | // client is the underlying GRPC client used to make calls to the server. | 140 | // client is the underlying GRPC client used to make calls to the server. |
139 | client GRPCBrokerClient | 141 | client plugin.GRPCBrokerClient |
140 | 142 | ||
141 | // send is used to send connection info to the gRPC stream. | 143 | // send is used to send connection info to the gRPC stream. |
142 | send chan *sendErr | 144 | send chan *sendErr |
143 | 145 | ||
144 | // recv is used to receive connection info from the gRPC stream. | 146 | // recv is used to receive connection info from the gRPC stream. |
145 | recv chan *ConnInfo | 147 | recv chan *plugin.ConnInfo |
146 | 148 | ||
147 | // quit closes down the stream. | 149 | // quit closes down the stream. |
148 | quit chan struct{} | 150 | quit chan struct{} |
@@ -153,9 +155,9 @@ type gRPCBrokerClientImpl struct { | |||
153 | 155 | ||
154 | func newGRPCBrokerClient(conn *grpc.ClientConn) *gRPCBrokerClientImpl { | 156 | func newGRPCBrokerClient(conn *grpc.ClientConn) *gRPCBrokerClientImpl { |
155 | return &gRPCBrokerClientImpl{ | 157 | return &gRPCBrokerClientImpl{ |
156 | client: NewGRPCBrokerClient(conn), | 158 | client: plugin.NewGRPCBrokerClient(conn), |
157 | send: make(chan *sendErr), | 159 | send: make(chan *sendErr), |
158 | recv: make(chan *ConnInfo), | 160 | recv: make(chan *plugin.ConnInfo), |
159 | quit: make(chan struct{}), | 161 | quit: make(chan struct{}), |
160 | } | 162 | } |
161 | } | 163 | } |
@@ -207,7 +209,7 @@ func (s *gRPCBrokerClientImpl) StartStream() error { | |||
207 | 209 | ||
208 | // Send is used by the GRPCBroker to pass connection information into the stream | 210 | // Send is used by the GRPCBroker to pass connection information into the stream |
209 | // to the plugin. | 211 | // to the plugin. |
210 | func (s *gRPCBrokerClientImpl) Send(i *ConnInfo) error { | 212 | func (s *gRPCBrokerClientImpl) Send(i *plugin.ConnInfo) error { |
211 | ch := make(chan error) | 213 | ch := make(chan error) |
212 | defer close(ch) | 214 | defer close(ch) |
213 | 215 | ||
@@ -225,7 +227,7 @@ func (s *gRPCBrokerClientImpl) Send(i *ConnInfo) error { | |||
225 | 227 | ||
226 | // Recv is used by the GRPCBroker to pass connection information that has been | 228 | // Recv is used by the GRPCBroker to pass connection information that has been |
227 | // sent from the plugin to the broker. | 229 | // sent from the plugin to the broker. |
228 | func (s *gRPCBrokerClientImpl) Recv() (*ConnInfo, error) { | 230 | func (s *gRPCBrokerClientImpl) Recv() (*plugin.ConnInfo, error) { |
229 | select { | 231 | select { |
230 | case <-s.quit: | 232 | case <-s.quit: |
231 | return nil, errors.New("broker closed") | 233 | return nil, errors.New("broker closed") |
@@ -266,7 +268,7 @@ type GRPCBroker struct { | |||
266 | } | 268 | } |
267 | 269 | ||
268 | type gRPCBrokerPending struct { | 270 | type gRPCBrokerPending struct { |
269 | ch chan *ConnInfo | 271 | ch chan *plugin.ConnInfo |
270 | doneCh chan struct{} | 272 | doneCh chan struct{} |
271 | } | 273 | } |
272 | 274 | ||
@@ -288,7 +290,7 @@ func (b *GRPCBroker) Accept(id uint32) (net.Listener, error) { | |||
288 | return nil, err | 290 | return nil, err |
289 | } | 291 | } |
290 | 292 | ||
291 | err = b.streamer.Send(&ConnInfo{ | 293 | err = b.streamer.Send(&plugin.ConnInfo{ |
292 | ServiceId: id, | 294 | ServiceId: id, |
293 | Network: listener.Addr().Network(), | 295 | Network: listener.Addr().Network(), |
294 | Address: listener.Addr().String(), | 296 | Address: listener.Addr().String(), |
@@ -363,7 +365,7 @@ func (b *GRPCBroker) Close() error { | |||
363 | 365 | ||
364 | // Dial opens a connection by ID. | 366 | // Dial opens a connection by ID. |
365 | func (b *GRPCBroker) Dial(id uint32) (conn *grpc.ClientConn, err error) { | 367 | func (b *GRPCBroker) Dial(id uint32) (conn *grpc.ClientConn, err error) { |
366 | var c *ConnInfo | 368 | var c *plugin.ConnInfo |
367 | 369 | ||
368 | // Open the stream | 370 | // Open the stream |
369 | p := b.getStream(id) | 371 | p := b.getStream(id) |
@@ -433,7 +435,7 @@ func (m *GRPCBroker) getStream(id uint32) *gRPCBrokerPending { | |||
433 | } | 435 | } |
434 | 436 | ||
435 | m.streams[id] = &gRPCBrokerPending{ | 437 | m.streams[id] = &gRPCBrokerPending{ |
436 | ch: make(chan *ConnInfo, 1), | 438 | ch: make(chan *plugin.ConnInfo, 1), |
437 | doneCh: make(chan struct{}), | 439 | doneCh: make(chan struct{}), |
438 | } | 440 | } |
439 | return m.streams[id] | 441 | return m.streams[id] |