Versions in this module Expand all Collapse all v0 v0.1.0 Nov 25, 2026 Changes in this version + const DefaultShards + var ErrEmptyTopic = errors.New("hourglass: empty topic") + var ErrMissingDue = errors.New("hourglass: no due time (use At or Delay)") + var ErrWheelFull = errors.New("hourglass: wheel at capacity") + func RegisterExecutorServer(srv *grpc.Server, es *executorServer) + func ShardFor(id string) int + type Clock interface + Now func() time.Time + type Cluster struct + func (c *Cluster) Close() error + func (c *Cluster) DropShard(sh ScanUnit) error + func (c *Cluster) KillForTest() + func (c *Cluster) Register(topic string, h Handler) + func (c *Cluster) Run(ctx context.Context) + type Config struct + Engine engineConfig + Etcd []string + LeaseTTL time.Duration + MySQL string + Shards []int + type ExecAck struct + Err string + Ok bool + RescheduleAt int64 + type ExecRequest struct + Attempt int + FiredId string + JobId string + Payload []byte + Topic string + type ExecutorClient struct + func NewExecutorClient(cc *grpc.ClientConn) *ExecutorClient + func (c *ExecutorClient) Exec(ctx context.Context, req *ExecRequest) (*ExecAck, error) + type Handle struct + func Open(dsn string) (*Handle, error) + func OpenWithClock(dsn string, clk Clock) (*Handle, error) + func (h *Handle) Cancel(ctx context.Context, id, reason string) error + func (h *Handle) Close() error + func (h *Handle) Eng() *engine + func (h *Handle) Every(ctx context.Context, topic, spec string) (string, error) + func (h *Handle) Get(ctx context.Context, id string) (*Job, error) + func (h *Handle) ListDead(ctx context.Context, topic string, limit int) ([]Job, error) + func (h *Handle) Ping(ctx context.Context) error + func (h *Handle) Register(topic string, fn Handler) + func (h *Handle) ReplayAllDead(ctx context.Context) (int, error) + func (h *Handle) ReplayDead(ctx context.Context, id string) error + func (h *Handle) Run(ctx context.Context) + func (h *Handle) Stats(ctx context.Context) (*Stats, error) + func (h *Handle) Submit(ctx context.Context, topic string, payload []byte, opts ...SubmitOption) (string, error) + type Handler func(ctx context.Context, j Job) error + type Job struct + Attempts int + Backoff time.Duration + CancelReason string + CreatedAt time.Time + Cron string + Due time.Time + ID string + MaxAttempts int + Payload []byte + ScheduledAt time.Time + Shard int + State State + Topic string + type Node struct + func Join(cfg Config) (*Node, error) + func (n *Node) AddShard(ctx context.Context, shard int) error + func (n *Node) Cancel(ctx context.Context, id, reason string) error + func (n *Node) Close() error + func (n *Node) EnginesForTest() map[string]struct{} + func (n *Node) Get(ctx context.Context, id string) (*Job, error) + func (n *Node) Handover(ctx context.Context, shard int) error + func (n *Node) KillForTest() + func (n *Node) Register(topic string, h Handler) + func (n *Node) Run(ctx context.Context) + func (n *Node) Submit(ctx context.Context, topic string, payload []byte, opts ...SubmitOption) (string, error) + type Receipt struct + At time.Time + Attempt int + Error string + ID string + JobID string + Kind string + Reason string + type ScanUnit string + type State string + const Acquired + const Canceled + const Completed + const Dead + const Fired + const Waiting + type StateCount struct + Count int64 + State State + type Stats struct + JobsByState []StateCount + OldestTerminal time.Time + TotalJobs int64 + TotalReceipts int64 + type Store interface + Acquire func(ctx context.Context, unit ScanUnit, epoch uint64, ids []string) ([]Job, error) + Get func(ctx context.Context, id string) (*Job, error) + Insert func(ctx context.Context, j *Job) error + Ping func(ctx context.Context) error + Select func(ctx context.Context, unit ScanUnit, from, to time.Time, n int) ([]Job, error) + type StoreExt interface + Reclaim func(ctx context.Context, unit ScanUnit, epoch uint64, ttl time.Duration) (int, error) + type SubmitOption func(*submitConfig) + func At(t time.Time) SubmitOption + func Delay(d time.Duration) SubmitOption + func InShard(n int) SubmitOption + func Jitter(w time.Duration) SubmitOption + func Retries(n int) SubmitOption + func RetryBackoff(d time.Duration) SubmitOption