jobv1

package
v0.0.0-...-9bfccdf Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Job_Start_FullMethodName  = "/job.v1.Job/Start"
	Job_Stop_FullMethodName   = "/job.v1.Job/Stop"
	Job_Status_FullMethodName = "/job.v1.Job/Status"
	Job_List_FullMethodName   = "/job.v1.Job/List"
	Job_Output_FullMethodName = "/job.v1.Job/Output"
)

Variables

View Source
var (
	State_name = map[int32]string{
		0: "UNKNOWN",
		1: "PENDING",
		2: "FAILED",
		3: "RUNNING",
		4: "TERMINATED",
	}
	State_value = map[string]int32{
		"UNKNOWN":    0,
		"PENDING":    1,
		"FAILED":     2,
		"RUNNING":    3,
		"TERMINATED": 4,
	}
)

Enum value maps for State.

View Source
var File_github_com_kralicky_jobserver_pkg_apis_job_v1_job_proto protoreflect.FileDescriptor
View Source
var Job_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "job.v1.Job",
	HandlerType: (*JobServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Start",
			Handler:    _Job_Start_Handler,
		},
		{
			MethodName: "Stop",
			Handler:    _Job_Stop_Handler,
		},
		{
			MethodName: "Status",
			Handler:    _Job_Status_Handler,
		},
		{
			MethodName: "List",
			Handler:    _Job_List_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Output",
			Handler:       _Job_Output_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "github.com/kralicky/jobserver/pkg/apis/job/v1/job.proto",
}

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

Functions

func RegisterJobServer

func RegisterJobServer(s grpc.ServiceRegistrar, srv JobServer)

Types

type CommandSpec

type CommandSpec struct {

	// The command name to run. Required.
	Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
	// The command's arguments, not containing the command name itself.
	Args []string `protobuf:"bytes,2,rep,name=args,proto3" json:"args,omitempty"`
	// Optional additional environment variables to set for the command.
	// These will be merged with the job server's environment variables.
	Env []string `protobuf:"bytes,3,rep,name=env,proto3" json:"env,omitempty"`
	// contains filtered or unexported fields
}

func (*CommandSpec) Descriptor deprecated

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

Deprecated: Use CommandSpec.ProtoReflect.Descriptor instead.

func (*CommandSpec) GetArgs

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

func (*CommandSpec) GetCommand

func (x *CommandSpec) GetCommand() string

func (*CommandSpec) GetEnv

func (x *CommandSpec) GetEnv() []string

func (*CommandSpec) ProtoMessage

func (*CommandSpec) ProtoMessage()

func (*CommandSpec) ProtoReflect

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

func (*CommandSpec) Reset

func (x *CommandSpec) Reset()

func (*CommandSpec) String

func (x *CommandSpec) String() string

type IODeviceLimits

type IODeviceLimits struct {

	// Device path (e.g. /dev/sda)
	Device string `protobuf:"bytes,1,opt,name=device,proto3" json:"device,omitempty"`
	// Limits for the device
	Limits *IOLimits `protobuf:"bytes,2,opt,name=limits,proto3" json:"limits,omitempty"`
	// contains filtered or unexported fields
}

func (*IODeviceLimits) Descriptor deprecated

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

Deprecated: Use IODeviceLimits.ProtoReflect.Descriptor instead.

func (*IODeviceLimits) GetDevice

func (x *IODeviceLimits) GetDevice() string

func (*IODeviceLimits) GetLimits

func (x *IODeviceLimits) GetLimits() *IOLimits

func (*IODeviceLimits) ProtoMessage

func (*IODeviceLimits) ProtoMessage()

func (*IODeviceLimits) ProtoReflect

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

func (*IODeviceLimits) Reset

func (x *IODeviceLimits) Reset()

func (*IODeviceLimits) String

func (x *IODeviceLimits) String() string

type IOLimits

type IOLimits struct {

	// Limit for read operations in bytes per second
	ReadBps *int64 `protobuf:"varint,2,opt,name=read_bps,json=readBps,proto3,oneof" json:"read_bps,omitempty"`
	// Limit for write operations in bytes per second
	WriteBps *int64 `protobuf:"varint,3,opt,name=write_bps,json=writeBps,proto3,oneof" json:"write_bps,omitempty"`
	// Limit for read operations in IOPS
	ReadIops *int64 `protobuf:"varint,4,opt,name=read_iops,json=readIops,proto3,oneof" json:"read_iops,omitempty"`
	// Limit for write operations in IOPS
	WriteIops *int64 `protobuf:"varint,5,opt,name=write_iops,json=writeIops,proto3,oneof" json:"write_iops,omitempty"`
	// contains filtered or unexported fields
}

func (*IOLimits) Descriptor deprecated

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

Deprecated: Use IOLimits.ProtoReflect.Descriptor instead.

func (*IOLimits) GetReadBps

func (x *IOLimits) GetReadBps() int64

func (*IOLimits) GetReadIops

func (x *IOLimits) GetReadIops() int64

func (*IOLimits) GetWriteBps

func (x *IOLimits) GetWriteBps() int64

func (*IOLimits) GetWriteIops

func (x *IOLimits) GetWriteIops() int64

func (*IOLimits) ProtoMessage

func (*IOLimits) ProtoMessage()

func (*IOLimits) ProtoReflect

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

func (*IOLimits) Reset

func (x *IOLimits) Reset()

func (*IOLimits) String

func (x *IOLimits) String() string

type JobClient

type JobClient interface {
	// Starts a new job, and returns its id if it was started successfully.
	//
	// The job will be run asynchronously; this method does not wait for it
	// to complete.
	//
	// The job's process will be run in its own cgroup which will exist for the
	// lifetime of the process. Optionally, all resource limits set in the
	// 'limits' field will be applied to the cgroup before it is started.
	Start(ctx context.Context, in *JobSpec, opts ...grpc.CallOption) (*JobId, error)
	// Stops a running job. Once stopped, this method will wait until the job has
	// completed before returning.
	//
	// This will first attempt to stop the job's process using SIGTERM, but if the
	// process does not exit within a short grace period, it will be forcefully
	// killed with SIGKILL.
	//
	// A job must be in the Running state to be stopped. If the job is in any
	// other state, this returns a FailedPrecondition error.
	Stop(ctx context.Context, in *JobId, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// Returns the status of an existing job.
	//
	// If the job is completed, detailed termination status will be present in
	// the response. Jobs stopped by the user with the Stop() method will
	// additionally have the 'stopped' field set to true.
	//
	// In the event the job failed to start, the 'message' field will contain a
	// human-readable error message. Otherwise, it will contain a description of
	// the current state (if running), or an explanation for why the job was
	// terminated (if terminated).
	Status(ctx context.Context, in *JobId, opts ...grpc.CallOption) (*JobStatus, error)
	// Returns a list of all job IDs that are currently known to the server.
	//
	// All jobs, regardless of state, are included. No guarantees are made about
	// the order of ids in the list.
	List(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*JobIdList, error)
	// Streams the combined stdout and stderr output of a running or completed job.
	//
	// The output always starts from the beginning of process execution, and will
	// be written to the stream in real-time until the job completes, or until the
	// stream is cancelled by the client.
	//
	// Jobs that were stopped by the user with the Stop() method will have output
	// up to the time they were stopped.
	//
	// If the job is already completed, the full output of the job will be
	// written to the stream, after which the stream will be closed.
	Output(ctx context.Context, in *JobId, opts ...grpc.CallOption) (Job_OutputClient, error)
}

JobClient is the client API for Job 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 NewJobClient

func NewJobClient(cc grpc.ClientConnInterface) JobClient

type JobId

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

func (*JobId) Descriptor deprecated

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

Deprecated: Use JobId.ProtoReflect.Descriptor instead.

func (*JobId) GetId

func (x *JobId) GetId() string

func (*JobId) ProtoMessage

func (*JobId) ProtoMessage()

func (*JobId) ProtoReflect

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

func (*JobId) Reset

func (x *JobId) Reset()

func (*JobId) String

func (x *JobId) String() string

type JobIdList

type JobIdList struct {
	Items []*JobId `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

func (*JobIdList) Descriptor deprecated

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

Deprecated: Use JobIdList.ProtoReflect.Descriptor instead.

func (*JobIdList) GetItems

func (x *JobIdList) GetItems() []*JobId

func (*JobIdList) ProtoMessage

func (*JobIdList) ProtoMessage()

func (*JobIdList) ProtoReflect

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

func (*JobIdList) Reset

func (x *JobIdList) Reset()

func (*JobIdList) String

func (x *JobIdList) String() string

type JobServer

type JobServer interface {
	// Starts a new job, and returns its id if it was started successfully.
	//
	// The job will be run asynchronously; this method does not wait for it
	// to complete.
	//
	// The job's process will be run in its own cgroup which will exist for the
	// lifetime of the process. Optionally, all resource limits set in the
	// 'limits' field will be applied to the cgroup before it is started.
	Start(context.Context, *JobSpec) (*JobId, error)
	// Stops a running job. Once stopped, this method will wait until the job has
	// completed before returning.
	//
	// This will first attempt to stop the job's process using SIGTERM, but if the
	// process does not exit within a short grace period, it will be forcefully
	// killed with SIGKILL.
	//
	// A job must be in the Running state to be stopped. If the job is in any
	// other state, this returns a FailedPrecondition error.
	Stop(context.Context, *JobId) (*emptypb.Empty, error)
	// Returns the status of an existing job.
	//
	// If the job is completed, detailed termination status will be present in
	// the response. Jobs stopped by the user with the Stop() method will
	// additionally have the 'stopped' field set to true.
	//
	// In the event the job failed to start, the 'message' field will contain a
	// human-readable error message. Otherwise, it will contain a description of
	// the current state (if running), or an explanation for why the job was
	// terminated (if terminated).
	Status(context.Context, *JobId) (*JobStatus, error)
	// Returns a list of all job IDs that are currently known to the server.
	//
	// All jobs, regardless of state, are included. No guarantees are made about
	// the order of ids in the list.
	List(context.Context, *emptypb.Empty) (*JobIdList, error)
	// Streams the combined stdout and stderr output of a running or completed job.
	//
	// The output always starts from the beginning of process execution, and will
	// be written to the stream in real-time until the job completes, or until the
	// stream is cancelled by the client.
	//
	// Jobs that were stopped by the user with the Stop() method will have output
	// up to the time they were stopped.
	//
	// If the job is already completed, the full output of the job will be
	// written to the stream, after which the stream will be closed.
	Output(*JobId, Job_OutputServer) error
	// contains filtered or unexported methods
}

JobServer is the server API for Job service. All implementations must embed UnimplementedJobServer for forward compatibility

type JobSpec

type JobSpec struct {
	Command *CommandSpec    `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"`
	Limits  *ResourceLimits `protobuf:"bytes,2,opt,name=limits,proto3" json:"limits,omitempty"`
	// contains filtered or unexported fields
}

JobSpec describes a command to be run, along with optional resource limits that should be applied to the command's process.

func (*JobSpec) Descriptor deprecated

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

Deprecated: Use JobSpec.ProtoReflect.Descriptor instead.

func (*JobSpec) GetCommand

func (x *JobSpec) GetCommand() *CommandSpec

func (*JobSpec) GetLimits

func (x *JobSpec) GetLimits() *ResourceLimits

func (*JobSpec) ProtoMessage

func (*JobSpec) ProtoMessage()

func (*JobSpec) ProtoReflect

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

func (*JobSpec) Reset

func (x *JobSpec) Reset()

func (*JobSpec) String

func (x *JobSpec) String() string

type JobStatus

type JobStatus struct {

	// The job's logical state.
	State State `protobuf:"varint,1,opt,name=state,proto3,enum=job.v1.State" json:"state,omitempty"`
	// The job's original spec.
	Spec *JobSpec `protobuf:"bytes,2,opt,name=spec,proto3" json:"spec,omitempty"`
	// A human-readable message describing the job's state, or an error message
	// if the job failed.
	Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
	// The PID of the job's process. Only present if the job is in the Running
	// or Terminated state.
	Pid int32 `protobuf:"varint,4,opt,name=pid,proto3" json:"pid,omitempty"`
	// The time at which the job was started. Only present if the job is
	// in the Running or Terminated state.
	StartTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
	// Termination details. Only present if the job is in the Terminated state.
	Terminated *TerminationStatus `protobuf:"bytes,6,opt,name=terminated,proto3" json:"terminated,omitempty"`
	// contains filtered or unexported fields
}

func (*JobStatus) Descriptor deprecated

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

Deprecated: Use JobStatus.ProtoReflect.Descriptor instead.

func (*JobStatus) GetMessage

func (x *JobStatus) GetMessage() string

func (*JobStatus) GetPid

func (x *JobStatus) GetPid() int32

func (*JobStatus) GetSpec

func (x *JobStatus) GetSpec() *JobSpec

func (*JobStatus) GetStartTime

func (x *JobStatus) GetStartTime() *timestamppb.Timestamp

func (*JobStatus) GetState

func (x *JobStatus) GetState() State

func (*JobStatus) GetTerminated

func (x *JobStatus) GetTerminated() *TerminationStatus

func (*JobStatus) ProtoMessage

func (*JobStatus) ProtoMessage()

func (*JobStatus) ProtoReflect

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

func (*JobStatus) Reset

func (x *JobStatus) Reset()

func (*JobStatus) String

func (x *JobStatus) String() string

type Job_OutputClient

type Job_OutputClient interface {
	Recv() (*ProcessOutput, error)
	grpc.ClientStream
}

type Job_OutputServer

type Job_OutputServer interface {
	Send(*ProcessOutput) error
	grpc.ServerStream
}

type MemoryLimits

type MemoryLimits struct {

	// Memory soft limit defined in bytes. Processes exceeding the limit are
	// not OOM-killed, but may be throttled by the kernel.
	SoftLimit *int64 `protobuf:"varint,1,opt,name=soft_limit,json=softLimit,proto3,oneof" json:"soft_limit,omitempty"`
	// Memory limit defined in bytes. If exceeded, the process will be OOM-killed.
	Limit *int64 `protobuf:"varint,2,opt,name=limit,proto3,oneof" json:"limit,omitempty"`
	// contains filtered or unexported fields
}

func (*MemoryLimits) Descriptor deprecated

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

Deprecated: Use MemoryLimits.ProtoReflect.Descriptor instead.

func (*MemoryLimits) GetLimit

func (x *MemoryLimits) GetLimit() int64

func (*MemoryLimits) GetSoftLimit

func (x *MemoryLimits) GetSoftLimit() int64

func (*MemoryLimits) ProtoMessage

func (*MemoryLimits) ProtoMessage()

func (*MemoryLimits) ProtoReflect

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

func (*MemoryLimits) Reset

func (x *MemoryLimits) Reset()

func (*MemoryLimits) String

func (x *MemoryLimits) String() string

type ProcessOutput

type ProcessOutput struct {

	// A chunk of output from the process's combined stdout and stderr streams.
	//
	// This is a raw byte stream, and may contain arbitrary binary data,
	// depending on the command being run. It is up to the client to interpret
	// the output correctly based on the command being run. No guarantees are
	// made about the size of each chunk, or the frequency at which they
	// are sent.
	Output []byte `protobuf:"bytes,1,opt,name=output,proto3" json:"output,omitempty"`
	// contains filtered or unexported fields
}

func (*ProcessOutput) Descriptor deprecated

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

Deprecated: Use ProcessOutput.ProtoReflect.Descriptor instead.

func (*ProcessOutput) GetOutput

func (x *ProcessOutput) GetOutput() []byte

func (*ProcessOutput) ProtoMessage

func (*ProcessOutput) ProtoMessage()

func (*ProcessOutput) ProtoReflect

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

func (*ProcessOutput) Reset

func (x *ProcessOutput) Reset()

func (*ProcessOutput) String

func (x *ProcessOutput) String() string

type ResourceLimits

type ResourceLimits struct {

	// Process CPU limit defined in milli-cores (1000 = 1 core/vcpu)
	Cpu *int64 `protobuf:"varint,1,opt,name=cpu,proto3,oneof" json:"cpu,omitempty"`
	// Process memory limit defined in bytes
	Memory *MemoryLimits `protobuf:"bytes,2,opt,name=memory,proto3" json:"memory,omitempty"`
	// Process IO limits for storage devices
	Io []*IODeviceLimits `protobuf:"bytes,3,rep,name=io,proto3" json:"io,omitempty"`
	// contains filtered or unexported fields
}

func (*ResourceLimits) Descriptor deprecated

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

Deprecated: Use ResourceLimits.ProtoReflect.Descriptor instead.

func (*ResourceLimits) GetCpu

func (x *ResourceLimits) GetCpu() int64

func (*ResourceLimits) GetIo

func (x *ResourceLimits) GetIo() []*IODeviceLimits

func (*ResourceLimits) GetMemory

func (x *ResourceLimits) GetMemory() *MemoryLimits

func (*ResourceLimits) ProtoMessage

func (*ResourceLimits) ProtoMessage()

func (*ResourceLimits) ProtoReflect

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

func (*ResourceLimits) Reset

func (x *ResourceLimits) Reset()

func (*ResourceLimits) String

func (x *ResourceLimits) String() string

type State

type State int32

State describes the logical state of a job.

┌─────────────────────────────────────────┐
│                                         │
│              ┌────────┐                 │
│      ┌──────►│ Failed │                 │
│      │       └────────┘                 │
│ ┌────┴────┐              ┌────────────┐ │
│ │ Pending │              │ Terminated │ │
│ └────┬────┘              └────────────┘ │
│      │       ┌─────────┐        ▲       │
│      └──────►│ Running ├────────┘       │
│              └─────────┘                │
│                                         │
└─────────────────────────────────────────┘
const (
	State_UNKNOWN State = 0
	// The job is waiting to be started, and is not yet running.
	State_PENDING State = 1
	// The job failed to start.
	State_FAILED State = 2
	// The job started successfully and is currently running.
	State_RUNNING State = 3
	// The job is no longer running.
	State_TERMINATED State = 4
)

func (State) Descriptor

func (State) Descriptor() protoreflect.EnumDescriptor

func (State) Enum

func (x State) Enum() *State

func (State) EnumDescriptor deprecated

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

Deprecated: Use State.Descriptor instead.

func (State) Number

func (x State) Number() protoreflect.EnumNumber

func (State) String

func (x State) String() string

func (State) Type

func (State) Type() protoreflect.EnumType

type TerminationStatus

type TerminationStatus struct {

	// If the process exited normally, this will contain its exit code. Otherwise,
	// if it was terminated by a signal, it will not be present.
	ExitCode int32 `protobuf:"varint,1,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"`
	// If the process was terminated by a signal, this will contain the signal
	// number. Otherwise, it will not be present.
	Signal int32 `protobuf:"varint,2,opt,name=signal,proto3" json:"signal,omitempty"`
	// If the process was stopped by the user with the Stop() method, this will
	// be true. Otherwise, it will be false.
	Stopped bool `protobuf:"varint,3,opt,name=stopped,proto3" json:"stopped,omitempty"`
	// The time at which the process was terminated.
	Time *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=time,proto3" json:"time,omitempty"`
	// contains filtered or unexported fields
}

Contains details about the cause of the process's termination.

func (*TerminationStatus) Descriptor deprecated

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

Deprecated: Use TerminationStatus.ProtoReflect.Descriptor instead.

func (*TerminationStatus) GetExitCode

func (x *TerminationStatus) GetExitCode() int32

func (*TerminationStatus) GetSignal

func (x *TerminationStatus) GetSignal() int32

func (*TerminationStatus) GetStopped

func (x *TerminationStatus) GetStopped() bool

func (*TerminationStatus) GetTime

func (x *TerminationStatus) GetTime() *timestamppb.Timestamp

func (*TerminationStatus) ProtoMessage

func (*TerminationStatus) ProtoMessage()

func (*TerminationStatus) ProtoReflect

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

func (*TerminationStatus) Reset

func (x *TerminationStatus) Reset()

func (*TerminationStatus) String

func (x *TerminationStatus) String() string

type UnimplementedJobServer

type UnimplementedJobServer struct {
}

UnimplementedJobServer must be embedded to have forward compatible implementations.

func (UnimplementedJobServer) List

func (UnimplementedJobServer) Output

func (UnimplementedJobServer) Start

func (UnimplementedJobServer) Status

func (UnimplementedJobServer) Stop

type UnsafeJobServer

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

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

Jump to

Keyboard shortcuts

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