Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode takes a Message struct and marshals it into a byte slice using msgpack. If the marshalling process encounters an error, the function will panic. It returns the marshalled byte slice.
Parameters:
- m: A pointer to the Message struct to be encoded.
Returns:
- A byte slice containing the msgpack-encoded data.
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:"-" msgpack:"-"`
// 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" msgpack:"timeout"`
// Payload is the payload data of the task.
Body []byte `json:"body" msgpack:"body"`
// RetryCount set count of retry
// default is 0, no retry.
RetryCount int64 `json:"retry_count" msgpack:"retry_count"`
// RetryDelay set delay between retry
// default is 100ms
RetryDelay time.Duration `json:"retry_delay" msgpack:"retry_delay"`
// RetryFactor is the multiplying factor for each increment step.
//
// Defaults to 2.
RetryFactor float64 `json:"retry_factor" msgpack:"retry_factor"`
// Minimum value of the counter.
//
// Defaults to 100 milliseconds.
RetryMin time.Duration `json:"retry_min" msgpack:"retry_min"`
// Maximum value of the counter.
//
// Defaults to 10 seconds.
RetryMax time.Duration `json:"retry_max" msgpack:"retry_max"`
// Jitter eases contention by randomizing backoff steps
Jitter bool `json:"jitter" msgpack:"jitter"`
}
Message describes a task and its metadata.
func Decode ¶
Decode takes a byte slice and unmarshals it into a Message struct using msgpack. If the unmarshalling process encounters an error, the function will panic. It returns a pointer to the unmarshalled Message.
Parameters:
- b: A byte slice containing the msgpack-encoded data.
Returns:
- A pointer to the decoded Message struct.
func NewMessage ¶
func NewMessage(m core.QueuedMessage, opts ...AllowOption) Message
NewMessage create new message
func NewTask ¶
func NewTask(task TaskFunc, opts ...AllowOption) Message
Click to show internal directories.
Click to hide internal directories.