aboutsummaryrefslogtreecommitdiff
path: root/executor/executor_plugin.go
diff options
context:
space:
mode:
Diffstat (limited to 'executor/executor_plugin.go')
-rw-r--r--executor/executor_plugin.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/executor/executor_plugin.go b/executor/executor_plugin.go
new file mode 100644
index 0000000..6eb7b35
--- /dev/null
+++ b/executor/executor_plugin.go
@@ -0,0 +1,34 @@
+package executor
+
+import (
+ "context"
+
+ hclog "github.com/hashicorp/go-hclog"
+ plugin "github.com/hashicorp/go-plugin"
+ "github.com/hashicorp/nomad/drivers/shared/executor/proto"
+ "google.golang.org/grpc"
+)
+
+type ExecutorPlugin struct {
+ // TODO: support backwards compatibility with pre 0.9 NetRPC plugin
+ plugin.NetRPCUnsupportedPlugin
+ logger hclog.Logger
+ fsIsolation bool
+}
+
+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
+}
+
+func (p *ExecutorPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
+ return &grpcExecutorClient{
+ client: proto.NewExecutorClient(c),
+ doneCtx: ctx,
+ logger: p.logger,
+ }, nil
+}