executor

package
v0.17.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2023 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

View Source
const ProtocolVersion = 1

ProtocolVersion is the version that must match between Botkube core and Botkube plugins. This should be bumped whenever a change happens in one or the other that makes it so that they can't safely communicate. This could be adding a new interface value, it could be how helper/schema computes diffs, etc.

NOTE: In the future we can consider using VersionedPlugins. These can be used to negotiate a compatible version between client and server. If this is set, Handshake.ProtocolVersion is not required.

Variables

View Source
var Executor_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "executor.Executor",
	HandlerType: (*ExecutorServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Execute",
			Handler:    _Executor_Execute_Handler,
		},
		{
			MethodName: "Metadata",
			Handler:    _Executor_Metadata_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "executor.proto",
}

Executor_ServiceDesc is the grpc.ServiceDesc for Executor service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_executor_proto protoreflect.FileDescriptor

Functions

func RegisterExecutorServer

func RegisterExecutorServer(s grpc.ServiceRegistrar, srv ExecutorServer)

func Serve

func Serve(p map[string]plugin.Plugin)

Serve serves given plugins.

Types

type Config

type Config struct {

	// RawYAML contains the Executor configuration in YAML definitions.
	RawYAML []byte `protobuf:"bytes,1,opt,name=rawYAML,proto3" json:"rawYAML,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetRawYAML

func (x *Config) GetRawYAML() []byte

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type ExecuteInput

type ExecuteInput struct {
	// Command holds the command to be executed.
	Command string
	// Configs is a list of Executor configurations specified by users.
	Configs []*Config
}

ExecuteInput holds the input of the Execute function.

type ExecuteOutput

type ExecuteOutput struct {
	// Data represent the output of processing a given input command.
	Data string
}

ExecuteOutput holds the output of the Execute function.

type ExecuteRequest

type ExecuteRequest struct {

	// Commands represents the exact command that was specified by the user.
	Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
	// Configs is a list of Executor configurations specified by users.
	Configs []*Config `protobuf:"bytes,2,rep,name=configs,proto3" json:"configs,omitempty"`
	// contains filtered or unexported fields
}

func (*ExecuteRequest) Descriptor deprecated

func (*ExecuteRequest) Descriptor() ([]byte, []int)

Deprecated: Use ExecuteRequest.ProtoReflect.Descriptor instead.

func (*ExecuteRequest) GetCommand

func (x *ExecuteRequest) GetCommand() string

func (*ExecuteRequest) GetConfigs

func (x *ExecuteRequest) GetConfigs() []*Config

func (*ExecuteRequest) ProtoMessage

func (*ExecuteRequest) ProtoMessage()

func (*ExecuteRequest) ProtoReflect

func (x *ExecuteRequest) ProtoReflect() protoreflect.Message

func (*ExecuteRequest) Reset

func (x *ExecuteRequest) Reset()

func (*ExecuteRequest) String

func (x *ExecuteRequest) String() string

type ExecuteResponse

type ExecuteResponse struct {
	Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*ExecuteResponse) Descriptor deprecated

func (*ExecuteResponse) Descriptor() ([]byte, []int)

Deprecated: Use ExecuteResponse.ProtoReflect.Descriptor instead.

func (*ExecuteResponse) GetData

func (x *ExecuteResponse) GetData() string

func (*ExecuteResponse) ProtoMessage

func (*ExecuteResponse) ProtoMessage()

func (*ExecuteResponse) ProtoReflect

func (x *ExecuteResponse) ProtoReflect() protoreflect.Message

func (*ExecuteResponse) Reset

func (x *ExecuteResponse) Reset()

func (*ExecuteResponse) String

func (x *ExecuteResponse) String() string

type Executor

type Executor interface {
	Execute(context.Context, ExecuteInput) (ExecuteOutput, error)
	Metadata(ctx context.Context) (api.MetadataOutput, error)
}

Executor defines the Botkube executor plugin functionality.

type ExecutorClient

type ExecutorClient interface {
	Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (*ExecuteResponse, error)
	Metadata(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*MetadataResponse, error)
}

ExecutorClient is the client API for Executor service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewExecutorClient

func NewExecutorClient(cc grpc.ClientConnInterface) ExecutorClient

type ExecutorServer

type ExecutorServer interface {
	Execute(context.Context, *ExecuteRequest) (*ExecuteResponse, error)
	Metadata(context.Context, *emptypb.Empty) (*MetadataResponse, error)
	// contains filtered or unexported methods
}

ExecutorServer is the server API for Executor service. All implementations must embed UnimplementedExecutorServer for forward compatibility

type MetadataResponse

type MetadataResponse struct {
	Version     string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"`
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// contains filtered or unexported fields
}

func (*MetadataResponse) Descriptor deprecated

func (*MetadataResponse) Descriptor() ([]byte, []int)

Deprecated: Use MetadataResponse.ProtoReflect.Descriptor instead.

func (*MetadataResponse) GetDescription

func (x *MetadataResponse) GetDescription() string

func (*MetadataResponse) GetVersion

func (x *MetadataResponse) GetVersion() string

func (*MetadataResponse) ProtoMessage

func (*MetadataResponse) ProtoMessage()

func (*MetadataResponse) ProtoReflect

func (x *MetadataResponse) ProtoReflect() protoreflect.Message

func (*MetadataResponse) Reset

func (x *MetadataResponse) Reset()

func (*MetadataResponse) String

func (x *MetadataResponse) String() string

type Plugin

type Plugin struct {
	// The GRPC plugin must still implement the Plugin interface.
	plugin.NetRPCUnsupportedPlugin

	// Executor represent a concrete implementation that handles the business logic.
	Executor Executor
}

Plugin This is the implementation of plugin.GRPCPlugin, so we can serve and consume different Botkube Executors.

func (*Plugin) GRPCClient

func (p *Plugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient returns the interface implementation for the plugin that is serving via gRPC by GRPCServer.

func (*Plugin) GRPCServer

func (p *Plugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers plugin for serving with the given GRPCServer.

type UnimplementedExecutorServer

type UnimplementedExecutorServer struct {
}

UnimplementedExecutorServer must be embedded to have forward compatible implementations.

func (UnimplementedExecutorServer) Execute

func (UnimplementedExecutorServer) Metadata

type UnsafeExecutorServer

type UnsafeExecutorServer interface {
	// contains filtered or unexported methods
}

UnsafeExecutorServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ExecutorServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL