job

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(val bool) *bool

Bool is a helper routine that allocates a new bool value

func Encode

func Encode(m *Message) []byte

Encode for encoding the structure

func Float64

func Float64(val float64) *float64

Float64 is a helper routine that allocates a new float64 value

func Int64

func Int64(val int64) *int64

Int64 is a helper routine that allocates a new int64 value

func Time

func Time(v time.Duration) *time.Duration

Time is a helper routine that allocates a new time value

Types

type AllowOption

type AllowOption struct {
	RetryCount  *int64
	RetryDelay  *time.Duration
	RetryFactor *float64
	RetryMin    *time.Duration
	RetryMax    *time.Duration
	Jitter      *bool
	Timeout     *time.Duration
}

AllowOption is a function that sets some option on the Options

type Message

type Message struct {
	Task TaskFunc `json:"-"`

	// Timeout is the duration the task can be processed by Handler.
	// zero if not specified
	// default is 60 time.Minute
	Timeout time.Duration `json:"timeout"`

	// Payload is the payload data of the task.
	Payload []byte `json:"body"`

	// RetryCount set count of retry
	// default is 0, no retry.
	RetryCount int64 `json:"retry_count"`

	// RetryDelay set delay between retry
	// default is 100ms
	RetryDelay time.Duration `json:"retry_delay"`

	// RetryFactor is the multiplying factor for each increment step.
	//
	// Defaults to 2.
	RetryFactor float64 `json:"retry_factor"`

	// Minimum value of the counter.
	//
	// Defaults to 100 milliseconds.
	RetryMin time.Duration `json:"retry_min"`

	// Maximum value of the counter.
	//
	// Defaults to 10 seconds.
	RetryMax time.Duration `json:"retry_max"`

	// Jitter eases contention by randomizing backoff steps
	Jitter bool `json:"jitter"`

	// Data to save Unsafe cast
	Data []byte
}

Message describes a task and its metadata.

func Decode

func Decode(m []byte) *Message

Decode for decoding the structure

func NewMessage

func NewMessage(m core.QueuedMessage, opts ...AllowOption) Message

NewMessage create new message

func NewTask

func NewTask(task TaskFunc, opts ...AllowOption) Message

NewTask create new task

func (*Message) Bytes

func (m *Message) Bytes() []byte

Bytes get internal data

func (*Message) Encode

func (m *Message) Encode()

Encode for encoding the structure

type Options

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

Options is a set of options for the queue

func NewOptions

func NewOptions(opts ...AllowOption) Options

NewOptions create new options

type TaskFunc

type TaskFunc func(context.Context) error

TaskFunc is the task function

Jump to

Keyboard shortcuts

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