open-nomad/drivers/shared/executor/executor_plugin.go

34 lines
915 B
Go
Raw Normal View History

2018-11-29 13:59:53 +00:00
package executor
2016-02-03 19:54:54 +00:00
import (
"context"
2016-02-03 19:54:54 +00:00
hclog "github.com/hashicorp/go-hclog"
2016-02-03 19:54:54 +00:00
"github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/drivers/shared/executor/proto"
"google.golang.org/grpc"
2016-02-03 19:54:54 +00:00
)
type ExecutorPlugin struct {
2018-12-08 06:52:06 +00:00
// TODO: support backwards compatibility with pre 0.9 NetRPC plugin
plugin.NetRPCUnsupportedPlugin
logger hclog.Logger
fsIsolation bool
2016-02-03 19:54:54 +00:00
}
func (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
if p.fsIsolation {
proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutorWithIsolation(p.logger)})
} else {
proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: NewExecutor(p.logger)})
}
return nil
2016-02-03 19:54:54 +00:00
}
func (p *ExecutorPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
return &grpcExecutorClient{
client: proto.NewExecutorClient(c),
doneCtx: ctx,
}, nil
2016-02-03 19:54:54 +00:00
}