go-workq: github.com/iamduo/go-workq Index | Files

package workq

import "github.com/iamduo/go-workq"

Package workq implements Workq protocol commands: https://github.com/iamduo/workq/blob/master/doc/protocol.md#commands

Index

Package Files

client.go error.go job.go

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")
)

func NewNetError Uses

func NewNetError(text string) error

func NewResponseError Uses

func NewResponseError(code string, text string) error

type BgJob Uses

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 Uses

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

Client represents a single connection to Workq.

func Connect Uses

func Connect(addr string) (*Client, error)

Connect to a Workq server returning a Client

func NewClient Uses

func NewClient(conn net.Conn) *Client

NewClient returns a Client from a net.Conn.

func (*Client) Add Uses

func (c *Client) Add(j *BgJob) error

"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) Close Uses

func (c *Client) Close() error

Close client connection.

func (*Client) Complete Uses

func (c *Client) Complete(id string, result []byte) error

"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 Uses

func (c *Client) Delete(id string) error

"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 Uses

func (c *Client) Fail(id string, result []byte) error

"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 Uses

func (c *Client) Lease(names []string, timeout int) (*LeasedJob, error)

"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 Uses

func (c *Client) Result(id string, timeout int) (*JobResult, error)

"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 Uses

func (c *Client) Run(j *FgJob) (*JobResult, error)

"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 Uses

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 Uses

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 JobResult Uses

type JobResult struct {
    Success bool
    Result  []byte
}

JobResult is returned by the "run" & "result" commands.

type LeasedJob Uses

type LeasedJob struct {
    ID      string
    Name    string
    TTR     int
    Payload []byte
}

LeasedJob is returned by the "lease" command.

type NetError Uses

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

func (*NetError) Error Uses

func (e *NetError) Error() string

type ResponseError Uses

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

func (*ResponseError) Code Uses

func (e *ResponseError) Code() string

func (*ResponseError) Error Uses

func (e *ResponseError) Error() string

func (*ResponseError) Text Uses

func (e *ResponseError) Text() string

type ScheduledJob Uses

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.

Package workq imports 9 packages (graph). Updated 2017-09-25. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).