Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ProcessHandler 的返回值,表示当前 task 需要 retry or archive ErrSkipRetry = errors.New("shoule retry later") )
Functions ¶
This section is empty.
Types ¶
type ErrorHandler ¶
An ErrorHandler handles an error occured during task processing.
type ErrorHandlerFunc ¶
The ErrorHandlerFunc type is an adapter to allow the use of ordinary functions as a ErrorHandler. If f is a function with the appropriate signature, ErrorHandlerFunc(f) is a ErrorHandler that calls f.
func (ErrorHandlerFunc) HandleError ¶
func (fn ErrorHandlerFunc) HandleError(ctx context.Context, task *Task, err error)
HandleError calls fn(ctx, task, err)
type HandlerFunc ¶
The HandlerFunc type is an adapter to allow the use of ordinary functions as a Handler. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.
func (HandlerFunc) ProcessTask ¶
func (fn HandlerFunc) ProcessTask(ctx context.Context, task *Task) error
ProcessTask calls fn(ctx, task)
type Logger ¶
type Logger interface { // Debug logs a message at Debug level. Debug(args ...interface{}) // Info logs a message at Info level. Info(args ...interface{}) Infof(format string, args ...interface{}) // Warn logs a message at Warning level. Warn(args ...interface{}) Warnf(format string, args ...interface{}) // Error logs a message at Error level. Error(args ...interface{}) Errorf(format string, args ...interface{}) }
type Payload ¶
type Payload struct {
// contains filtered or unexported fields
}
Payload holds arbitrary data needed for task execution.
type ProcessHandler ¶
A ProcessHandler processes tasks.
ProcessTask should return nil if the processing of a task is successful.
If ProcessTask return a non-nil error or panics, the task will be retried after delay. One exception to this rule is when ProcessTask returns SkipRetry error. If the returned error is SkipRetry or the error wraps SkipRetry, retry is skipped and task will be archived instead.
type RetryDelayFunc ¶
RetryDelayFunc calculates the retry delay duration for a failed task given the retry count, error, and the task.
n is the number of times the task canhas been retry. e is the error returned by the task handler. t is the task in question.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(ops ...ServerOption) *Server
type ServerOption ¶
type ServerOption func(s *Server)
func WithBroker ¶
func WithBroker(b broker.CtxBroker) ServerOption
func WithLogger ¶
func WithLogger(l Logger) ServerOption