-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbridge.go
36 lines (31 loc) · 1013 Bytes
/
bridge.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package textilebots
import (
plugin "github.com/hashicorp/go-plugin"
shared "github.com/textileio/go-textile-core/bots"
proto "github.com/textileio/go-textile-core/bots/pb"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
// This is the implementation of plugin.Plugin so we can serve/consume this.
// We also implement GRPCPlugin so that this plugin can be served over
// gRPC.
type TextileBot struct {
plugin.NetRPCUnsupportedPlugin
// Concrete implementation, written in Go. This is only used for plugins
// that are written in Go.
Impl shared.Service
}
func (p *TextileBot) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
proto.RegisterBotserviceServer(s, &GRPCServer{
Impl: p.Impl,
broker: broker,
})
return nil
}
func (p *TextileBot) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
return &GRPCClient{
client: proto.NewBotserviceClient(c),
broker: broker,
}, nil
}
var _ plugin.GRPCPlugin = &TextileBot{}