Documentation ¶
Overview ¶
Package workq implements Workq protocol commands: https://github.com/iamduo/workq/blob/master/doc/protocol.md#commands
Index ¶
- Constants
- Variables
- func NewNetError(text string) error
- func NewResponseError(code string, text string) error
- type BgJob
- type Client
- func (c *Client) Add(j *BgJob) error
- func (c *Client) Close() error
- func (c *Client) Complete(id string, result []byte) error
- func (c *Client) Delete(id string) error
- func (c *Client) Fail(id string, result []byte) error
- func (c *Client) Lease(names []string, timeout int) (*LeasedJob, error)
- func (c *Client) Result(id string, timeout int) (*JobResult, error)
- func (c *Client) Run(j *FgJob) (*JobResult, error)
- func (c *Client) Schedule(j *ScheduledJob) error
- type FgJob
- type JobResult
- type LeasedJob
- type NetError
- type ResponseError
- type ScheduledJob
Constants ¶
const (
// Time format for any date times. Compatible with time.Format.
TimeFormat = "2006-01-02T15:04:05Z"
)
Variables ¶
var ( // ErrMalformed is returned when responses from workq can not be parsed // due to unrecognized responses. ErrMalformed = errors.New("Malformed response") )
Functions ¶
func NewNetError ¶
func NewResponseError ¶
Types ¶
type BgJob ¶
type BgJob struct { ID string Name string TTR int // Time-to-run TTL int // Time-to-live Payload []byte Priority int // Numeric priority MaxAttempts int // Absoulute max num of attempts. MaxFails int // Absolute max number of failures. }
BgJob is executed by the "add" command. Describes a background job specification.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a single connection to Workq.
func (*Client) Add ¶
"add" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#add
Add background job Returns ResponseError for Workq response errors. Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
func (*Client) Complete ¶
"complete" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#complete
Mark job successfully complete, @see PROTOCOL_DOC Returns ResponseError for Workq response errors. Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
func (*Client) Delete ¶
"delete" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#delete
Delete job. Returns ResponseError for Workq response errors. Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
func (*Client) Fail ¶
"fail" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#fail
Mark job as failure. Returns ResponseError for Workq response errors. Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
func (*Client) Lease ¶
"lease" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#lease
Lease a job, waiting for available jobs until timeout, @see PROTOCOL_DOC Returns ResponseError for Workq response errors. Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
func (*Client) Result ¶
"result" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#result
Fetch job result, @see PROTOCOL_DOC Returns ResponseError for Workq response errors. Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
func (*Client) Run ¶
"run" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#run
Submit foreground job and wait for result. Returns ResponseError for Workq response errors Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
func (*Client) Schedule ¶
func (c *Client) Schedule(j *ScheduledJob) error
"schedule" command: https://github.com/iamduo/workq/blob/master/doc/protocol.md#schedule
Schedule job at future UTC time. Returns ResponseError for Workq response errors. Returns NetError on any network errors. Returns ErrMalformed if response can't be parsed.
type FgJob ¶
type FgJob struct { ID string Name string TTR int Timeout int // Milliseconds to wait for job completion. Payload []byte Priority int // Numeric priority }
FgJob is executed by the "run" command. Describes a foreground job specification.
type ResponseError ¶
type ResponseError struct {
// contains filtered or unexported fields
}
func (*ResponseError) Code ¶
func (e *ResponseError) Code() string
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
func (*ResponseError) Text ¶
func (e *ResponseError) Text() string
type ScheduledJob ¶
type ScheduledJob struct { ID string Name string TTR int TTL int Payload []byte Time string Priority int // Numeric priority MaxAttempts int // Absoulute max num of attempts. MaxFails int // Absolute max number of failures. }
ScheduledJob is executed by the "schedule" command. Describes a scheduled job specification.