runner

package
v0.0.0-...-aa30a3e Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 25 Imported by: 0

README

Runner

Runner is a grpc service that runs binaries (typically other grpc services read from a file) as subprocesses that it communicates with over uds.

Documentation

Index

Constants

View Source
const (
	Runner_Batch_FullMethodName          = "/runner.Runner/Batch"
	Runner_Babble_FullMethodName         = "/runner.Runner/Babble"
	Runner_AppendAndPrint_FullMethodName = "/runner.Runner/AppendAndPrint"
	Runner_AddNewLine_FullMethodName     = "/runner.Runner/AddNewLine"
	Runner_Fork_FullMethodName           = "/runner.Runner/Fork"
	Runner_Spawn_FullMethodName          = "/runner.Runner/Spawn"
	Runner_Stop_FullMethodName           = "/runner.Runner/Stop"
)

Variables

View Source
var (
	PosixSpawnFlag_name = map[int32]string{
		0: "POSIX_SPAWN_UNKNOWN",
	}
	PosixSpawnFlag_value = map[string]int32{
		"POSIX_SPAWN_UNKNOWN": 0,
	}
)

Enum value maps for PosixSpawnFlag.

View Source
var (
	FileActionKind_name = map[int32]string{
		0: "FILEACTIONUNKNOWN",
		1: "FILEACTIONOPEN",
		2: "FILEACTIONCLOSE",
		3: "FILEACTIONDUP",
	}
	FileActionKind_value = map[string]int32{
		"FILEACTIONUNKNOWN": 0,
		"FILEACTIONOPEN":    1,
		"FILEACTIONCLOSE":   2,
		"FILEACTIONDUP":     3,
	}
)

Enum value maps for FileActionKind.

View Source
var File_runner_runner_proto protoreflect.FileDescriptor
View Source
var Runner_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "runner.Runner",
	HandlerType: (*RunnerServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Batch",
			Handler:    _Runner_Batch_Handler,
		},
		{
			MethodName: "Fork",
			Handler:    _Runner_Fork_Handler,
		},
		{
			MethodName: "Spawn",
			Handler:    _Runner_Spawn_Handler,
		},
		{
			MethodName: "Stop",
			Handler:    _Runner_Stop_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Babble",
			Handler:       _Runner_Babble_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "AppendAndPrint",
			Handler:       _Runner_AppendAndPrint_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
		{
			StreamName:    "AddNewLine",
			Handler:       _Runner_AddNewLine_Handler,
			ClientStreams: true,
		},
	},
	Metadata: "runner/runner.proto",
}

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

Functions

func InheritedConn

func InheritedConn() (net.Conn, error)

InheritedConn returns a net.Conn wrapping fd 3 if it exists. A forked child calls this to get its end of the socketpair.

func RegisterRunnerServer

func RegisterRunnerServer(s grpc.ServiceRegistrar, srv RunnerServer)

Types

type FileAction

type FileAction struct {
	Kind FileActionKind `protobuf:"varint,1,opt,name=kind,proto3,enum=runner.FileActionKind" json:"kind,omitempty"`
	Fd   int32          `protobuf:"varint,2,opt,name=fd,proto3" json:"fd,omitempty"`
	// contains filtered or unexported fields
}

func (*FileAction) Descriptor deprecated

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

Deprecated: Use FileAction.ProtoReflect.Descriptor instead.

func (*FileAction) GetFd

func (x *FileAction) GetFd() int32

func (*FileAction) GetKind

func (x *FileAction) GetKind() FileActionKind

func (*FileAction) ProtoMessage

func (*FileAction) ProtoMessage()

func (*FileAction) ProtoReflect

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

func (*FileAction) Reset

func (x *FileAction) Reset()

func (*FileAction) String

func (x *FileAction) String() string

type FileActionKind

type FileActionKind int32
const (
	FileActionKind_FILEACTIONUNKNOWN FileActionKind = 0
	FileActionKind_FILEACTIONOPEN    FileActionKind = 1
	FileActionKind_FILEACTIONCLOSE   FileActionKind = 2
	FileActionKind_FILEACTIONDUP     FileActionKind = 3
)

func (FileActionKind) Descriptor

func (FileActionKind) Enum

func (x FileActionKind) Enum() *FileActionKind

func (FileActionKind) EnumDescriptor deprecated

func (FileActionKind) EnumDescriptor() ([]byte, []int)

Deprecated: Use FileActionKind.Descriptor instead.

func (FileActionKind) Number

func (FileActionKind) String

func (x FileActionKind) String() string

func (FileActionKind) Type

type ForkRequest

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

func (*ForkRequest) Descriptor deprecated

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

Deprecated: Use ForkRequest.ProtoReflect.Descriptor instead.

func (*ForkRequest) ProtoMessage

func (*ForkRequest) ProtoMessage()

func (*ForkRequest) ProtoReflect

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

func (*ForkRequest) Reset

func (x *ForkRequest) Reset()

func (*ForkRequest) String

func (x *ForkRequest) String() string

type Pipe

type Pipe struct {
	InputPath  string                                `protobuf:"bytes,1,opt,name=input_path,json=inputPath,proto3" json:"input_path,omitempty"`
	Pipeline   []*descriptorpb.MethodDescriptorProto `protobuf:"bytes,2,rep,name=pipeline,proto3" json:"pipeline,omitempty"`
	OutputPath string                                `protobuf:"bytes,3,opt,name=output_path,json=outputPath,proto3" json:"output_path,omitempty"`
	// contains filtered or unexported fields
}

func (*Pipe) Descriptor deprecated

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

Deprecated: Use Pipe.ProtoReflect.Descriptor instead.

func (*Pipe) GetInputPath

func (x *Pipe) GetInputPath() string

func (*Pipe) GetOutputPath

func (x *Pipe) GetOutputPath() string

func (*Pipe) GetPipeline

func (x *Pipe) GetPipeline() []*descriptorpb.MethodDescriptorProto

func (*Pipe) ProtoMessage

func (*Pipe) ProtoMessage()

func (*Pipe) ProtoReflect

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

func (*Pipe) Reset

func (x *Pipe) Reset()

func (*Pipe) String

func (x *Pipe) String() string

type PosixSpawnFlag

type PosixSpawnFlag int32

TODO: we should cleanup/remove these and also check the way we are encoding them actually matches the attrp object.

const (
	// Proto3 requires the first enum value to be 0.
	PosixSpawnFlag_POSIX_SPAWN_UNKNOWN PosixSpawnFlag = 0
)

func (PosixSpawnFlag) Descriptor

func (PosixSpawnFlag) Enum

func (x PosixSpawnFlag) Enum() *PosixSpawnFlag

func (PosixSpawnFlag) EnumDescriptor deprecated

func (PosixSpawnFlag) EnumDescriptor() ([]byte, []int)

Deprecated: Use PosixSpawnFlag.Descriptor instead.

func (PosixSpawnFlag) Number

func (PosixSpawnFlag) String

func (x PosixSpawnFlag) String() string

func (PosixSpawnFlag) Type

type Process

type Process struct {
	Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"`
	// contains filtered or unexported fields
}

func (*Process) Descriptor deprecated

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

Deprecated: Use Process.ProtoReflect.Descriptor instead.

func (*Process) GetPid

func (x *Process) GetPid() int32

func (*Process) ProtoMessage

func (*Process) ProtoMessage()

func (*Process) ProtoReflect

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

func (*Process) Reset

func (x *Process) Reset()

func (*Process) String

func (x *Process) String() string

type RunnerClient

type RunnerClient interface {
	// Fork once for each member of the pipeline, create an intermediate pipe to buffer processing to the child and remove one method and set the child's input path to the pipe. Once child is created and setup (and connected to), start reading from input_path into MethodDescriptorProto until consumed
	Batch(ctx context.Context, in *Pipe, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// given a string eg "What I learned in boating school is" create 50 permutations of the words
	Babble(ctx context.Context, in *StringValue, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StringValue], error)
	// add a random char to the end
	AppendAndPrint(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[StringValue, StringValue], error)
	AddNewLine(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[StringValue, StringValue], error)
	// Fork forks the current process into a duplicate new process
	Fork(ctx context.Context, in *ForkRequest, opts ...grpc.CallOption) (*Process, error)
	// Spawn implements Posix Spawn https://man7.org/linux/man-pages/man3/posix_spawn.3.html
	Spawn(ctx context.Context, in *SpawnRequest, opts ...grpc.CallOption) (*Process, error)
	Stop(ctx context.Context, in *StopRequest, opts ...grpc.CallOption) (*StopResponse, error)
}

RunnerClient is the client API for Runner 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.

Runner service handles execution of binaries as subprocesses

func NewRunnerClient

func NewRunnerClient(cc grpc.ClientConnInterface) RunnerClient

type RunnerServer

type RunnerServer interface {
	// Fork once for each member of the pipeline, create an intermediate pipe to buffer processing to the child and remove one method and set the child's input path to the pipe. Once child is created and setup (and connected to), start reading from input_path into MethodDescriptorProto until consumed
	Batch(context.Context, *Pipe) (*emptypb.Empty, error)
	// given a string eg "What I learned in boating school is" create 50 permutations of the words
	Babble(*StringValue, grpc.ServerStreamingServer[StringValue]) error
	// add a random char to the end
	AppendAndPrint(grpc.BidiStreamingServer[StringValue, StringValue]) error
	AddNewLine(grpc.ClientStreamingServer[StringValue, StringValue]) error
	// Fork forks the current process into a duplicate new process
	Fork(context.Context, *ForkRequest) (*Process, error)
	// Spawn implements Posix Spawn https://man7.org/linux/man-pages/man3/posix_spawn.3.html
	Spawn(context.Context, *SpawnRequest) (*Process, error)
	Stop(context.Context, *StopRequest) (*StopResponse, error)
	// contains filtered or unexported methods
}

RunnerServer is the server API for Runner service. All implementations must embed UnimplementedRunnerServer for forward compatibility.

Runner service handles execution of binaries as subprocesses

func NewRunnerServer

func NewRunnerServer() RunnerServer

type Runner_AddNewLineClient

type Runner_AddNewLineClient = grpc.ClientStreamingClient[StringValue, StringValue]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Runner_AddNewLineServer

type Runner_AddNewLineServer = grpc.ClientStreamingServer[StringValue, StringValue]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Runner_AppendAndPrintClient

type Runner_AppendAndPrintClient = grpc.BidiStreamingClient[StringValue, StringValue]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Runner_AppendAndPrintServer

type Runner_AppendAndPrintServer = grpc.BidiStreamingServer[StringValue, StringValue]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Runner_BabbleClient

type Runner_BabbleClient = grpc.ServerStreamingClient[StringValue]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type Runner_BabbleServer

type Runner_BabbleServer = grpc.ServerStreamingServer[StringValue]

This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.

type SpawnRequest

type SpawnRequest struct {
	Path    string            `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	Flags   []PosixSpawnFlag  `protobuf:"varint,2,rep,packed,name=flags,proto3,enum=runner.PosixSpawnFlag" json:"flags,omitempty"`
	Actions []*FileAction     `protobuf:"bytes,3,rep,name=actions,proto3" json:"actions,omitempty"`
	Args    []string          `protobuf:"bytes,4,rep,name=args,proto3" json:"args,omitempty"`
	Env     map[string]string `` /* 133-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*SpawnRequest) Descriptor deprecated

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

Deprecated: Use SpawnRequest.ProtoReflect.Descriptor instead.

func (*SpawnRequest) GetActions

func (x *SpawnRequest) GetActions() []*FileAction

func (*SpawnRequest) GetArgs

func (x *SpawnRequest) GetArgs() []string

func (*SpawnRequest) GetEnv

func (x *SpawnRequest) GetEnv() map[string]string

func (*SpawnRequest) GetFlags

func (x *SpawnRequest) GetFlags() []PosixSpawnFlag

func (*SpawnRequest) GetPath

func (x *SpawnRequest) GetPath() string

func (*SpawnRequest) ProtoMessage

func (*SpawnRequest) ProtoMessage()

func (*SpawnRequest) ProtoReflect

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

func (*SpawnRequest) Reset

func (x *SpawnRequest) Reset()

func (*SpawnRequest) String

func (x *SpawnRequest) String() string

type StopRequest

type StopRequest struct {
	ProcessId string `protobuf:"bytes,1,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"`
	// Whether to force kill (SIGKILL vs SIGTERM)
	Force bool `protobuf:"varint,2,opt,name=force,proto3" json:"force,omitempty"`
	// Timeout in seconds before force kill
	TimeoutSeconds int32 `protobuf:"varint,3,opt,name=timeout_seconds,json=timeoutSeconds,proto3" json:"timeout_seconds,omitempty"`
	// contains filtered or unexported fields
}

func (*StopRequest) Descriptor deprecated

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

Deprecated: Use StopRequest.ProtoReflect.Descriptor instead.

func (*StopRequest) GetForce

func (x *StopRequest) GetForce() bool

func (*StopRequest) GetProcessId

func (x *StopRequest) GetProcessId() string

func (*StopRequest) GetTimeoutSeconds

func (x *StopRequest) GetTimeoutSeconds() int32

func (*StopRequest) ProtoMessage

func (*StopRequest) ProtoMessage()

func (*StopRequest) ProtoReflect

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

func (*StopRequest) Reset

func (x *StopRequest) Reset()

func (*StopRequest) String

func (x *StopRequest) String() string

type StopResponse

type StopResponse struct {
	ProcessId string `protobuf:"bytes,1,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"`
	Success   bool   `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"`
	ExitCode  int32  `protobuf:"varint,3,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"`
	// contains filtered or unexported fields
}

func (*StopResponse) Descriptor deprecated

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

Deprecated: Use StopResponse.ProtoReflect.Descriptor instead.

func (*StopResponse) GetExitCode

func (x *StopResponse) GetExitCode() int32

func (*StopResponse) GetProcessId

func (x *StopResponse) GetProcessId() string

func (*StopResponse) GetSuccess

func (x *StopResponse) GetSuccess() bool

func (*StopResponse) ProtoMessage

func (*StopResponse) ProtoMessage()

func (*StopResponse) ProtoReflect

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

func (*StopResponse) Reset

func (x *StopResponse) Reset()

func (*StopResponse) String

func (x *StopResponse) String() string

type StringValue

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

func (*StringValue) Descriptor deprecated

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

Deprecated: Use StringValue.ProtoReflect.Descriptor instead.

func (*StringValue) GetValue

func (x *StringValue) GetValue() string

func (*StringValue) ProtoMessage

func (*StringValue) ProtoMessage()

func (*StringValue) ProtoReflect

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

func (*StringValue) Reset

func (x *StringValue) Reset()

func (*StringValue) String

func (x *StringValue) String() string

type UnimplementedRunnerServer

type UnimplementedRunnerServer struct{}

UnimplementedRunnerServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedRunnerServer) AddNewLine

func (UnimplementedRunnerServer) AppendAndPrint

func (UnimplementedRunnerServer) Babble

func (UnimplementedRunnerServer) Batch

func (UnimplementedRunnerServer) Fork

func (UnimplementedRunnerServer) Spawn

func (UnimplementedRunnerServer) Stop

type UnsafeRunnerServer

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

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

Jump to

Keyboard shortcuts

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