grpc

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJsonSchemaConvertion error = errors.New("failed to convert to json format")
	ErrJsonConvertion       error = errors.New("failed to convert to/from json")
)
View Source
var DefaultHandshake = plugin.HandshakeConfig{

	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_lugh_PLUGIN",
	MagicCookieValue: "hello",
}
View Source
var File_core_plugins_grpc_plugins_proto protoreflect.FileDescriptor
View Source
var IOWorkerPlugins_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "grpc.IOWorkerPlugins",
	HandlerType: (*IOWorkerPluginsServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetInputSchema",
			Handler:    _IOWorkerPlugins_GetInputSchema_Handler,
		},
		{
			MethodName: "Config",
			Handler:    _IOWorkerPlugins_Config_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Input",
			Handler:       _IOWorkerPlugins_Input_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "Output",
			Handler:       _IOWorkerPlugins_Output_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "Run",
			Handler:       _IOWorkerPlugins_Run_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "core/plugins/grpc/plugins.proto",
}

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

Functions

func CleanupClients

func CleanupClients()

func RegisterIOWorkerPluginsServer

func RegisterIOWorkerPluginsServer(s grpc.ServiceRegistrar, srv IOWorkerPluginsServer)

Types

type DataStream

type DataStream struct {
	Data       []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	ParentSrc  string `protobuf:"bytes,2,opt,name=parentSrc,proto3" json:"parentSrc,omitempty"`
	Id         string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
	IsComplete bool   `protobuf:"varint,4,opt,name=isComplete,proto3" json:"isComplete,omitempty"`
	TotalLen   int64  `protobuf:"varint,5,opt,name=totalLen,proto3" json:"totalLen,omitempty"`
	// contains filtered or unexported fields
}

func (*DataStream) Descriptor deprecated

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

Deprecated: Use DataStream.ProtoReflect.Descriptor instead.

func (*DataStream) GetData

func (x *DataStream) GetData() []byte

func (*DataStream) GetId

func (x *DataStream) GetId() string

func (*DataStream) GetIsComplete

func (x *DataStream) GetIsComplete() bool

func (*DataStream) GetParentSrc

func (x *DataStream) GetParentSrc() string

func (*DataStream) GetTotalLen

func (x *DataStream) GetTotalLen() int64

func (*DataStream) ProtoMessage

func (*DataStream) ProtoMessage()

func (*DataStream) ProtoReflect

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

func (*DataStream) Reset

func (x *DataStream) Reset()

func (*DataStream) String

func (x *DataStream) String() string

type Empty

type Empty struct {
	// contains filtered or unexported fields
}

func (*Empty) Descriptor deprecated

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

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

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

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

type Error

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

func (*Error) Descriptor deprecated

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

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

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

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

type GRPCClient

type GRPCClient struct {
	Name string
	// contains filtered or unexported fields
}

func NewGRPCClient

func NewGRPCClient(client IOWorkerPluginsClient, name string) *GRPCClient

func (*GRPCClient) Config

func (m *GRPCClient) Config(config []byte) error

func (*GRPCClient) GetInputSchema

func (m *GRPCClient) GetInputSchema() ([]byte, error)

func (*GRPCClient) Output

func (m *GRPCClient) Output() <-chan []byte

func (*GRPCClient) Run

func (m *GRPCClient) Run(ctx graph.SyncContext) <-chan error

func (*GRPCClient) SetInput

func (m *GRPCClient) SetInput(input <-chan []byte)

type GRPCServer

type GRPCServer struct {
	// This is the real implementation
	Impl pluginapi.IOWorkerPluginable
	Name string
}

Here is the gRPC server that GRPCClient talks to.

func (*GRPCServer) Config

func (m *GRPCServer) Config(ctx context.Context, config *RunInputConfig) (*Empty, error)

func (*GRPCServer) GetInputSchema

func (m *GRPCServer) GetInputSchema(context.Context, *Empty) (*InputSchema, error)

func (*GRPCServer) Input

func (m *GRPCServer) Input(stream IOWorkerPlugins_InputServer) error

func (*GRPCServer) Output

func (m *GRPCServer) Output(empty *Empty, stream IOWorkerPlugins_OutputServer) error

func (*GRPCServer) Run

type IOWorkerGRPCPlugin

type IOWorkerGRPCPlugin struct {
	// GRPCPlugin must still implement the Plugin interface
	goplugin.NetRPCUnsupportedPlugin
	Impl pluginapi.IOWorkerPluginable
	Name string
}

This is the implementation of plugin.GRPCPlugin so we can serve/consume this.

func (IOWorkerGRPCPlugin) GRPCClient

func (p IOWorkerGRPCPlugin) GRPCClient(ctx context.Context, broker *goplugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (IOWorkerGRPCPlugin) GRPCServer

func (p IOWorkerGRPCPlugin) GRPCServer(broker *goplugin.GRPCBroker, s *grpc.Server) error

type IOWorkerPluginsClient

type IOWorkerPluginsClient interface {
	GetInputSchema(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*InputSchema, error)
	Config(ctx context.Context, in *RunInputConfig, opts ...grpc.CallOption) (*Empty, error)
	Input(ctx context.Context, opts ...grpc.CallOption) (IOWorkerPlugins_InputClient, error)
	Output(ctx context.Context, in *Empty, opts ...grpc.CallOption) (IOWorkerPlugins_OutputClient, error)
	Run(ctx context.Context, in *Empty, opts ...grpc.CallOption) (IOWorkerPlugins_RunClient, error)
}

IOWorkerPluginsClient is the client API for IOWorkerPlugins 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.

type IOWorkerPluginsServer

type IOWorkerPluginsServer interface {
	GetInputSchema(context.Context, *Empty) (*InputSchema, error)
	Config(context.Context, *RunInputConfig) (*Empty, error)
	Input(IOWorkerPlugins_InputServer) error
	Output(*Empty, IOWorkerPlugins_OutputServer) error
	Run(*Empty, IOWorkerPlugins_RunServer) error
	// contains filtered or unexported methods
}

IOWorkerPluginsServer is the server API for IOWorkerPlugins service. All implementations must embed UnimplementedIOWorkerPluginsServer for forward compatibility

type IOWorkerPlugins_InputClient

type IOWorkerPlugins_InputClient interface {
	Send(*DataStream) error
	CloseAndRecv() (*Empty, error)
	grpc.ClientStream
}

type IOWorkerPlugins_InputServer

type IOWorkerPlugins_InputServer interface {
	SendAndClose(*Empty) error
	Recv() (*DataStream, error)
	grpc.ServerStream
}

type IOWorkerPlugins_OutputClient

type IOWorkerPlugins_OutputClient interface {
	Recv() (*DataStream, error)
	grpc.ClientStream
}

type IOWorkerPlugins_OutputServer

type IOWorkerPlugins_OutputServer interface {
	Send(*DataStream) error
	grpc.ServerStream
}

type IOWorkerPlugins_RunClient

type IOWorkerPlugins_RunClient interface {
	Recv() (*Error, error)
	grpc.ClientStream
}

type IOWorkerPlugins_RunServer

type IOWorkerPlugins_RunServer interface {
	Send(*Error) error
	grpc.ServerStream
}

type InputSchema

type InputSchema struct {
	Config []byte `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
	// contains filtered or unexported fields
}

func (*InputSchema) Descriptor deprecated

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

Deprecated: Use InputSchema.ProtoReflect.Descriptor instead.

func (*InputSchema) GetConfig

func (x *InputSchema) GetConfig() []byte

func (*InputSchema) ProtoMessage

func (*InputSchema) ProtoMessage()

func (*InputSchema) ProtoReflect

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

func (*InputSchema) Reset

func (x *InputSchema) Reset()

func (*InputSchema) String

func (x *InputSchema) String() string

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func NewPlugin

func NewPlugin(name string, opt ...PluginOption) *Plugin

func (*Plugin) Cleanup

func (p *Plugin) Cleanup()

func (*Plugin) Connect

func (p *Plugin) Connect() (pluginapi.IOWorkerPluginable, error)

func (Plugin) Serve

func (p Plugin) Serve()

type PluginOption

type PluginOption = helper.Option[Plugin]

func WithCmdConfig

func WithCmdConfig(cmd *exec.Cmd) PluginOption

func WithGRPCPlugin

func WithGRPCPlugin() PluginOption

func WithHandshakeConfig

func WithHandshakeConfig(handshakeConfig plugin.HandshakeConfig) PluginOption

func WithPath

func WithPath(path string) PluginOption

func WithPluginImplementation

func WithPluginImplementation(plugin pluginapi.IOWorkerPluginable) PluginOption

func WithPluginProcessPath

func WithPluginProcessPath(path string) PluginOption

type RunInputConfig

type RunInputConfig struct {
	Config []byte `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
	// contains filtered or unexported fields
}

func (*RunInputConfig) Descriptor deprecated

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

Deprecated: Use RunInputConfig.ProtoReflect.Descriptor instead.

func (*RunInputConfig) GetConfig

func (x *RunInputConfig) GetConfig() []byte

func (*RunInputConfig) ProtoMessage

func (*RunInputConfig) ProtoMessage()

func (*RunInputConfig) ProtoReflect

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

func (*RunInputConfig) Reset

func (x *RunInputConfig) Reset()

func (*RunInputConfig) String

func (x *RunInputConfig) String() string

type RunLoop

type RunLoop struct {
	// contains filtered or unexported fields
}

func NewRunLoop

func NewRunLoop() *RunLoop

func (*RunLoop) Recv

func (rl *RunLoop) Recv(stream *DataStream) *DataStream

func (*RunLoop) Send

func (rl *RunLoop) Send(stream *DataStream) []*DataStream

type UnimplementedIOWorkerPluginsServer

type UnimplementedIOWorkerPluginsServer struct {
}

UnimplementedIOWorkerPluginsServer must be embedded to have forward compatible implementations.

func (UnimplementedIOWorkerPluginsServer) Config

func (UnimplementedIOWorkerPluginsServer) GetInputSchema

func (UnimplementedIOWorkerPluginsServer) Input

func (UnimplementedIOWorkerPluginsServer) Output

func (UnimplementedIOWorkerPluginsServer) Run

type UnsafeIOWorkerPluginsServer

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

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

Jump to

Keyboard shortcuts

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