Documentation
¶
Index ¶
- Variables
- type Config
- type Envelope
- type Handler
- type Priority
- type Queue
- func (q *Queue) DeadLetter() <-chan Envelope
- func (q *Queue) Enqueue(ctx context.Context, taskType string, payload any) error
- func (q *Queue) EnqueueAt(_ context.Context, taskType string, payload any, p Priority) error
- func (q *Queue) Register(taskType string, h Handler)
- func (q *Queue) Start(ctx context.Context) error
- func (q *Queue) StartWithReadyCallback(ctx context.Context, onStarted func()) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrChannelFull = errors.New("channel full (backpressure)") ErrAlreadyStarted = errors.New("taskqueue: queue has already been started") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Name string
Workers int // per priority lane (Low gets half)
MaxAttempts int // default 5
BaseDelay time.Duration // exponential retry base, default 500ms
Logger *slog.Logger
}
Config controls queue behavior.
type Envelope ¶
type Envelope struct {
ID string `json:"id"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
Attempt int `json:"attempt"`
EnqueuedAt time.Time `json:"enqueued_at"`
}
Envelope is the data passed to handlers.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the in‑process task queue.
func (*Queue) DeadLetter ¶
func (*Queue) StartWithReadyCallback ¶ added in v0.9.0
StartWithReadyCallback begins processing workers, then calls onStarted once the worker goroutines have been launched. It blocks until ctx is canceled. The callback is optional and runs outside the queue's worker hot paths. A queue may only be started once; subsequent calls return ErrAlreadyStarted.
Click to show internal directories.
Click to hide internal directories.