Versions in this module Expand all Collapse all v1 v1.1.0 Mar 15, 2026 Changes in this version + var ErrClosed = errors.New("seqdelay: queue is closed") + var ErrDuplicateTask = errors.New("seqdelay: task already exists") + var ErrInvalidDelay = errors.New("seqdelay: delay must be positive") + var ErrInvalidState = errors.New("seqdelay: invalid task state for this operation") + var ErrInvalidTask = errors.New("seqdelay: task ID and Topic are required") + var ErrQueueFull = errors.New("seqdelay: ready queue is full") + var ErrRedisRequired = errors.New("seqdelay: redis connection is required") + var ErrTaskNotFound = errors.New("seqdelay: task not found") + var ErrTooManyTopics = errors.New("seqdelay: max topic count exceeded") + var ErrTopicConflict = errors.New("seqdelay: topic already has a callback registered") + type Option func(*config) + func WithInstanceID(id string) Option + func WithLockTTL(d time.Duration) Option + func WithMaxTopics(n int) Option + func WithPopTimeout(d time.Duration) Option + func WithReadyQueueSize(n int) Option + func WithRedis(addr string) Option + func WithRedisClient(client redis.UniversalClient) Option + func WithRedisCluster(addrs []string) Option + func WithRedisOptions(opts *redis.Options) Option + func WithRedisSentinel(addrs []string, master string) Option + func WithTickInterval(d time.Duration) Option + func WithWheelCapacity(n uint32) Option + type Queue struct + func New(opts ...Option) (*Queue, error) + func (q *Queue) Add(ctx context.Context, task *Task) error + func (q *Queue) Cancel(ctx context.Context, topic, id string) error + func (q *Queue) Finish(ctx context.Context, topic, id string) error + func (q *Queue) Get(ctx context.Context, topic, id string) (*Task, error) + func (q *Queue) OnExpire(topic string, fn func(context.Context, *Task) error) error + func (q *Queue) Pop(ctx context.Context, topic string) (*Task, error) + func (q *Queue) Shutdown(ctx context.Context) error + func (q *Queue) Start(ctx context.Context) error + type Server struct + func NewServer(q *Queue, opts ...ServerOption) *Server + func (s *Server) ListenAndServe() error + func (s *Server) Shutdown(ctx context.Context) error + type ServerOption func(*Server) + func WithServerAddr(addr string) ServerOption + type Task struct + ActiveAt time.Time + Body []byte + CreatedAt time.Time + Delay time.Duration + ID string + MaxRetries int + Retries int + State TaskState + TTR time.Duration + Topic string + func (t *Task) Validate() error + type TaskState int + const StateActive + const StateCancelled + const StateDelayed + const StateFinished + const StateReady + func (s TaskState) String() string