open-nomad/plugins/executor/executor_plugin.go

35 lines
980 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"
"github.com/hashicorp/nomad/plugins/executor/proto"
"google.golang.org/grpc"
2016-02-03 19:54:54 +00:00
)
type ExecutorPlugin struct {
// TODO: support backwards compatability 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: executor.NewExecutorWithIsolation(p.logger)})
} else {
proto.RegisterExecutorServer(s, &grpcExecutorServer{impl: executor.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
}