handlers

package
v0.0.0-...-fc15ddb Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxLimit = 100
)

Variables

View Source
var (
	ErrDuplicateJob       = prot.NewClientErr(job.ErrDuplicateJob.Error())
	ErrLeaseExpired       = prot.NewClientErr("Lease expired")
	ErrInvalidWaitTimeout = prot.NewClientErr("Invalid wait timeout")
)
View Source
var (
	ErrInvalidCursorOffset = prot.NewClientErr("Invalid cursor offset")
	ErrInvalidLimit        = prot.NewClientErr("Invalid limit")
)

Functions

func JobResp

func JobResp(rec *job.RunRecord, j *job.Job) []byte

Format a single job for inspect cmds.

func QueueResp

func QueueResp(name string, insp *job.Inspector) []byte

Format single Queue for inspect cmds.

Types

type AddHandler

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

func NewAddHandler

func NewAddHandler(jc job.Adder) *AddHandler

func (*AddHandler) Exec

func (h *AddHandler) Exec(cmd *prot.Cmd) ([]byte, error)

add <id> <name> <ttr> <ttl> <payload-size> [max-attempts=<value>] [max-fails=<value>] [-priority=<value>] <payload>

Adds a job to its named work queue with respect for <priority> TTL timer starts immmediately

Returns: CLIENT-ERROR on invalid input OK on success enqueue

type CompleteHandler

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

func NewCompleteHandler

func NewCompleteHandler(jc job.Completer) *CompleteHandler

func (*CompleteHandler) Exec

func (h *CompleteHandler) Exec(cmd *prot.Cmd) ([]byte, error)

complete <id> <result-size> <result>

Sucessfully complete a job with an optional result. Stops TTR timer.

Returns: CLIENT-ERROR * on invalid input NOT-FOUND if job does not exist OK on success

type DeleteHandler

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

func NewDeleteHandler

func NewDeleteHandler(jc job.Deleter) *DeleteHandler

func (*DeleteHandler) Exec

func (h *DeleteHandler) Exec(cmd *prot.Cmd) ([]byte, error)

`delete` <id>

Delete a job by id.

Returns: CLIENT-ERROR on invalid input NOT-FOUND if job does not exist OK if successful

type FailHandler

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

func NewFailHandler

func NewFailHandler(jc job.Failer) *FailHandler

func (*FailHandler) Exec

func (h *FailHandler) Exec(cmd *prot.Cmd) ([]byte, error)

fail <id> <result-size> <result>

Fails a job with an optional result. Stops any further TTR timer.

Returns: CLIENT-ERROR * on invalid input NOT-FOUND if job does not exist OK on success

type Handler

type Handler interface {
	Exec(cmd *prot.Cmd) ([]byte, error)
}

type InspectHandler

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

Primary Inspect Handler acts as a router to other sub inspect cmds

func NewInspectHandler

func NewInspectHandler(
	server Handler,
	queues Handler,
	queue Handler,
	jobs Handler,
	j Handler,
) *InspectHandler

func (*InspectHandler) Exec

func (h *InspectHandler) Exec(cmd *prot.Cmd) ([]byte, error)

inspect <object> Routes inspect commands to their individual object commands.

Returns: CLIENT-ERROR on invalid input UnknownCmd error invalid inspect object

type InspectJobHandler

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

func NewInspectJobHandler

func NewInspectJobHandler(reg *job.Registry) *InspectJobHandler

func (*InspectJobHandler) Exec

func (h *InspectJobHandler) Exec(cmd *prot.Cmd) ([]byte, error)

inspect job <id>

Show a single job by id.

Returns: CLIENT-ERROR on invalid input NOT-FOUND On invalid ID

type InspectJobsHandler

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

func (*InspectJobsHandler) Exec

func (h *InspectJobsHandler) Exec(cmd *prot.Cmd) ([]byte, error)

inspect jobs <name> <cursor-offset> <limit> & inspect scheduled-jobs <name> <cursor-offset> <limit>

Scan jobs by name with a cursor-offset and limit. <jobs> returns in priority,created-time order. <scheduled-jobs> returns in scheduled time, priority,created-time order.

Returns: CLIENT-ERROR in invalid input

type InspectQueueHandler

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

func (*InspectQueueHandler) Exec

func (h *InspectQueueHandler) Exec(cmd *prot.Cmd) ([]byte, error)

Inspect queue <name>

Show single queue info by name.

Returns: CLIENT-ERROR on invalid input NOT-FOUND when queue is not available

type InspectQueuesHandler

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

func (*InspectQueuesHandler) Exec

func (h *InspectQueuesHandler) Exec(cmd *prot.Cmd) ([]byte, error)

Inspect queues <cursor-offset> <limit>

Scan available queues based on a cursor-offset and limit. Returns queues in aplhabetical order.

Returns: CLIENT-ERROR on invalid input NOT-FOUND when queue is not available

type InspectServerHandler

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

func NewInspectServerHandler

func NewInspectServerHandler(s ServerStater, j JobStater) *InspectServerHandler

func (*InspectServerHandler) Exec

func (h *InspectServerHandler) Exec(cmd *prot.Cmd) ([]byte, error)

inspect server

Show general info on server state.

Returns: CLIENT-ERROR in invalid input

type JobStater

type JobStater interface {
	Stats() job.Stats
}

type LeaseHandler

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

func NewLeaseHandler

func NewLeaseHandler(jc job.Leaser) *LeaseHandler

func (*LeaseHandler) Exec

func (h *LeaseHandler) Exec(cmd *prot.Cmd) ([]byte, error)

lease <name>... <wait-timeout>

Lease a job by name blocking until wait-timeout. Multiple job names can be specified and they will be processed uniformly by random selection.

Returns:

CLIENT-ERROR * on invalid input. TIMEOUT if no jobs were available within <wait-timeout>. OK if successful with leased job response.

type ResultHandler

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

func NewResultHandler

func NewResultHandler(reg *job.Registry, qc job.QueueControllerInterface) *ResultHandler

func (*ResultHandler) Exec

func (h *ResultHandler) Exec(cmd *prot.Cmd) ([]byte, error)

`result` <id>...

Job result by id, blocking until wait-timeout.

Returns: CLIENT-ERROR on invalid input TIMEOUT if no job results are available OK if successful with result response

type RunHandler

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

func NewRunHandler

func NewRunHandler(jc job.Runner) *RunHandler

func (*RunHandler) Exec

func (h *RunHandler) Exec(cmd *prot.Cmd) ([]byte, error)

run <id> <name> <ttr> <wait-timeout> <payload-size> [-priority=<value>] <payload-bytes>

Run a job, blocking until wait-timeout if no workers are available, or until TTR if a worker is processing.

Returns:

CLIENT-ERROR on invalid input TIMEOUT if no workers were available within <wait-timeout> OK if successful with result response of executed job.

type ScheduleHandler

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

func NewScheduleHandler

func NewScheduleHandler(jc job.Scheduler) *ScheduleHandler

func (*ScheduleHandler) Exec

func (h *ScheduleHandler) Exec(cmd *prot.Cmd) ([]byte, error)

schedule <id> <name> <ttr> <ttl> <time> <payload-size> [max-attempts=<value>] [max-fails=<value>] [-priority=<value>] <payload>

Schedules a job to run at a UTC time with respect for <priority> TTL timer starts when scheduled time is met.

Returns: CLIENT-ERROR on invalid input OK on success enqueue

type ServerStater

type ServerStater interface {
	Stats() server.Stats
}

type UnknownHandler

type UnknownHandler struct{}

func (*UnknownHandler) Exec

func (h *UnknownHandler) Exec(cmd *prot.Cmd) ([]byte, error)

Jump to

Keyboard shortcuts

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