Versions in this module Expand all Collapse all v0 v0.1.1 Mar 24, 2026 v0.1.0 Mar 24, 2026 Changes in this version + var ErrEmptyTaskName = errors.New("natasks: task name is required") + var ErrHandlerNotFound = errors.New("natasks: handler not found") + var ErrNoRetry = errors.New("natasks: no retry") + func NoRetry(err error) error + type Client struct + func NewClient(js jetstream.JetStream, opts ...Option) (*Client, error) + func (c *Client) Dispatch(ctx context.Context, task *Task, queue string) error + func (c *Client) DispatchAt(ctx context.Context, task *Task, queue string, at time.Time) error + func (c *Client) DispatchIn(ctx context.Context, task *Task, queue string, delay time.Duration) error + func (c *Client) IsReady() bool + func (c *Client) WithLogger(logger *slog.Logger) *Client + type DispatchFunc func(context.Context, *Task, string) error + type DispatchMiddleware func(DispatchFunc) DispatchFunc + type Handler func(context.Context, *Task) error + type MessagePropagator interface + Extract func(context.Context, TextMapCarrier) context.Context + Inject func(context.Context, TextMapCarrier) + type Option interface + func WithDispatchMiddleware(middlewares ...DispatchMiddleware) Option + type ProcessMiddleware func(Handler) Handler + type SharedOption interface + func WithPropagator(propagator MessagePropagator) SharedOption + func WithStreamName(name string) SharedOption + func WithSubjectPrefix(prefix string) SharedOption + type Task struct + func NewTask(name string, payload []byte) (*Task, error) + func (t *Task) AddHeader(key, value string) *Task + func (t *Task) Header(key string) string + func (t *Task) Headers() nats.Header + func (t *Task) MessageID() string + func (t *Task) Name() string + func (t *Task) Payload() []byte + func (t *Task) SetHeader(key, value string) *Task + func (t *Task) Unmarshal(dst any) error + func (t *Task) WithMessageID(id string) *Task + type TextMapCarrier interface + Get func(string) string + Keys func() []string + Set func(string, string) + type Worker struct + func NewWorker(js jetstream.JetStream, queue string, opts ...WorkerOption) (*Worker, error) + func (w *Worker) Handle(name string, handler Handler) + func (w *Worker) IsReady() bool + func (w *Worker) Run(ctx context.Context) error + func (w *Worker) WithLogger(logger *slog.Logger) *Worker + type WorkerOption interface + func WithAckWait(wait time.Duration) WorkerOption + func WithConcurrency(n int) WorkerOption + func WithConsumerPrefix(prefix string) WorkerOption + func WithDLQSuffix(suffix string) WorkerOption + func WithDurable(name string) WorkerOption + func WithFetchBatch(size int) WorkerOption + func WithFetchTimeout(timeout time.Duration) WorkerOption + func WithIdleWait(wait time.Duration) WorkerOption + func WithMaxAckPending(n int) WorkerOption + func WithMaxRetries(n int) WorkerOption + func WithProcessMiddleware(middlewares ...ProcessMiddleware) WorkerOption + func WithProgressInterval(interval time.Duration) WorkerOption + func WithRetryBackoff(delays ...time.Duration) WorkerOption + func WithTaskTimeout(timeout time.Duration) WorkerOption