batch

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchClient

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

func NewBatchClient

func NewBatchClient(name string) (*BatchClient, error)

func (*BatchClient) Name

func (s *BatchClient) Name() string

func (*BatchClient) Submit

func (s *BatchClient) Submit(ctx context.Context, data map[string]interface{}) error

type BatchClientIn

type BatchClientIn interface {
	// Name returns the Job name.
	Name() string

	// Submit will submit the provided request to the job.
	Submit(ctx context.Context, data map[string]interface{}) error
}

Batch

type Ctx

type Ctx struct {
	Request  Request
	Response *Response
	Extras   map[string]interface{}
	// contains filtered or unexported fields
}

func NewCtx

func NewCtx(msg *batchpb.ServerMessage) *Ctx

func (*Ctx) ToClientMessage

func (c *Ctx) ToClientMessage() *batchpb.ClientMessage

func (*Ctx) WithError

func (c *Ctx) WithError(err error)

type Handler

type Handler = handlers.Handler[Ctx]

type HandlerOption

type HandlerOption func(opts *handlerOptions)

func WithCpus

func WithCpus(cpus float32) HandlerOption

WithCpus - Set the number of CPUs/vCPUs to allocate to job handler instances

func WithGpus

func WithGpus(gpus int64) HandlerOption

WithGpus - Set the number of GPUs to allocate to job handler instances

func WithMemory

func WithMemory(mib int64) HandlerOption

WithMemory - Set the amount of memory in MiB to allocate to job handler instances

type JobPermission

type JobPermission string

JobPermission defines the available permissions on a job

const (
	// JobSubmit is required to call Submit on a job.
	JobSubmit JobPermission = "submit"
)

type JobReference

type JobReference interface {
	// Allow requests the given permissions to the job.
	Allow(permission JobPermission, permissions ...JobPermission) *BatchClient

	// Handler will register and start the job task handler that will be called for all task submitted to this job.
	// Valid function signatures for middleware are:
	//
	//	func()
	//	func() error
	//	func(*batch.Ctx)
	//	func(*batch.Ctx) error
	//	Handler[batch.Ctx]
	Handler(handler interface{}, options ...HandlerOption)
}

func NewJob

func NewJob(name string) JobReference

NewJob creates a new job resource with the give name.

type Request

type Request interface {
	JobName() string
	Data() map[string]interface{}
}

type Response

type Response struct {
	Success bool
}

Jump to

Keyboard shortcuts

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