worker

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 19, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WorkerGoroutines

func WorkerGoroutines(goroutines int) func(*Client)

WorkerGoroutines set the quantity of goroutines used to process the queue.

func WorkerLogger

func WorkerLogger(logger log.Logger) func(*Client)

WorkerLogger set the worker logger.

func WorkerProcessor

func WorkerProcessor(processor Processor) func(*Client)

WorkerProcessor set the processor at Worker.

func WorkerPuller

func WorkerPuller(puller Puller) func(*Client)

WorkerPuller set the puller at worker.

func WorkerPusher

func WorkerPusher(pusher Pusher) func(*Client)

WorkerPusher set the pusher at worker.

func WorkerTimeout

func WorkerTimeout(timeout time.Duration) func(*Client)

WorkerTimeout set the default timeout duration for a task to process.

Types

type Client

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

Client implements the logic to process tasks.

func NewClient

func NewClient(options ...func(*Client)) (*Client, error)

NewClient returns a configured worker.

func (*Client) Push

func (c *Client) Push(ctx context.Context, content []byte) error

Push the task to be processed.

func (*Client) Start

func (c *Client) Start()

Start the worker to process tasks.

func (*Client) Stop

func (c *Client) Stop()

Stop the client.

type Processor

type Processor interface {
	Process(context.Context, []byte) error
}

Processor is used to process the tasks.

type Puller

type Puller interface {
	Pull(context.Context, func(context.Context, []byte) error) error
}

Puller is used to fetch a task to process.

type Pusher

type Pusher interface {
	Push(context.Context, []byte) error
}

Pusher is used to send a task to be processed.

Jump to

Keyboard shortcuts

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