jobdb

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: CC0-1.0, CC0-1.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTCPPort = 12360
	DefaultWSPort  = 80
)

The default ports that the jobdb server listens on.

Variables

View Source
var (
	ErrNilClient = errors.New("uninitialised client")
	ErrClosed    = errors.New("client is closed")
)

errors

Functions

This section is empty.

Types

type Client

type Client struct {
	log.BasicLogable
	io.Closer
	// contains filtered or unexported fields
}

Client is the client view of the server.

func NewClient

func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error)

NewClient returns a new client view of the server specified by the configuration cfg.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, id job.ID) error

Delete deletes the job with given ID.

func (*Client) Describe

func (c *Client) Describe(ctx context.Context, id job.ID) (*job.Specification, error)

Describe returns the submission data for the job with the given ID.

func (*Client) Download

func (c *Client) Download(ctx context.Context, id job.ID, path string) (job.Reader, error)

Download downloads a file with the given path. This should be present in the manifest for the job with the given ID.

func (*Client) Error

func (c *Client) Error(ctx context.Context, t job.Task) error

Error indicates that the task t has failed and should be retried.

func (*Client) Fatal

func (c *Client) Fatal(ctx context.Context, t job.Task) error

Fatal indicates that the task t has failed and should not be requeued.

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context, t job.Task) (bool, error)

Heartbeat sends a message to the job server indicating that the worker is still alive and is processing the task t. A nil value for t indicates that no task is being processed. Heartbeat returns true if task processing should continue and false if the current task should be cancelled.

func (*Client) Info

func (c *Client) Info(ctx context.Context, id job.ID, n int64) (job.Info, error)

Info returns information about the task with the given job ID and value n.

func (*Client) List

func (c *Client) List(ctx context.Context) ([]job.ID, error)

List returns a slice containing the IDs of all jobs.

func (*Client) ListWithPriority

func (c *Client) ListWithPriority(ctx context.Context, level job.Priority) ([]job.ID, error)

ListWithPriority returns a slice containing the IDs of all jobs with the given priority level.

func (*Client) Next

func (c *Client) Next(ctx context.Context, mt job.Metadata) (job.Task, error)

Next returns a new task, if one is available. It provides the metadata mt to the job server.

func (*Client) Requeue

func (c *Client) Requeue(ctx context.Context, t job.Task) error

Requeue indicates that the task t should be requeued, without incrementing the number of failures.

func (*Client) Status

func (c *Client) Status(ctx context.Context, id job.ID) (job.Status, error)

Status returns the status of the job with the given ID.

func (*Client) Submit

func (c *Client) Submit(ctx context.Context, spec *job.Specification) (job.ID, error)

Submit submits a job specified by spec, returning an ID which identifies that job.

func (*Client) Success

func (c *Client) Success(ctx context.Context, t job.Task) error

Success indicates that the task t has succeeded.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, id job.ID, path string, contents io.Reader) error

Upload uploads a file with the given path and contents. The path should be present in the manifest for the job with the given ID.

type ClientConfig

type ClientConfig struct {
	Address *address.Address // The address to connect to
	SSLCert []byte           // The SSL certificate(s) (if any)
}

ClientConfig describes the configuration options we allow a user to set on a jobdb client.

func DefaultClientConfig

func DefaultClientConfig() *ClientConfig

DefaultClientConfig returns a new client configuration initialised with the default values.

The initial default value for the hostname will be read from the environment variable PCAS_JOBDB_ADDRESS on package init. This should take the form "hostname[:port]" or "ws://host/path".

func SetDefaultClientConfig

func SetDefaultClientConfig(c *ClientConfig) *ClientConfig

SetDefaultClientConfig sets the default client configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultClientConfig.

func (*ClientConfig) Copy

func (c *ClientConfig) Copy() *ClientConfig

Copy returns a copy of the configuration.

func (*ClientConfig) URI

func (c *ClientConfig) URI() string

URI returns the URI connection string.

Note that the returned string may differ slightly from the value returned c.Address.URI(). For example, if c.Address omits a port number, an appropriate default port number is used here.

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

Validate validates the client configuration, returning an error if there's a problem.

type Option

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

Option sets options on a jobdb server.

func SSLCertAndKey

func SSLCertAndKey(crt []byte, key []byte) Option

SSLCertAndKey adds the given SSL public certificate and private key to the server.

func WithStorage

func WithStorage(s job.Storage) Option

WithStorage sets the underlying storage system used by the server.

type Server

Server handles client communication.

func NewServer

func NewServer(options ...Option) (*Server, error)

NewServer returns a new jobdb server.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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