github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/drivers/shared/executor/executor_plugin.go (about) 1 package executor 2 3 import ( 4 "context" 5 6 hclog "github.com/hashicorp/go-hclog" 7 plugin "github.com/hashicorp/go-plugin" 8 "github.com/hashicorp/nomad/drivers/shared/executor/proto" 9 "google.golang.org/grpc" 10 ) 11 12 type ExecutorPlugin struct { 13 // TODO: support backwards compatibility with pre 0.9 NetRPC plugin 14 plugin.NetRPCUnsupportedPlugin 15 logger hclog.Logger 16 fsIsolation bool 17 } 18 19 func (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error { 20 if p.fsIsolation { 21 proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutorWithIsolation(p.logger)}) 22 } else { 23 proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutor(p.logger)}) 24 } 25 return nil 26 } 27 28 func (p *ExecutorPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) { 29 return &grpcExecutorClient{ 30 client: proto.NewExecutorClient(c), 31 doneCtx: ctx, 32 logger: p.logger, 33 }, nil 34 }