Help us shape the future of Go! Take the 2026 Go Developer Survey

scheduler

package
v1.21.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scheduler enqueues the periodic tasks on their schedules, in the application's time zone. Every replica runs a scheduler; a tick's task id names its slot, so the replicas' enqueues of one slot collapse into one task.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service enqueues the periodic tasks. Every process runs one, so a tick is enqueued under a task ID naming the task type and the tick's slot: the replicas firing for the same slot collide on that ID (asynq keeps it while the task is pending, running, retrying or retained as completed) and only the first enqueue lands. asynq.Unique cannot do this: it releases its lock as soon as the task succeeds, so a replica ticking after that enqueues the slot again. A slot's task never blocks the next slot, however long it runs.

func NewService

func NewService(redisOpt asynq.RedisConnOpt, appLocation string) *Service

NewService builds the scheduler on the queue's Redis connection; the composition root owns that connection's settings.

func (*Service) Start

func (m *Service) Start()

Start registers the periodic tasks and blocks until Stop.

func (*Service) Stop

func (m *Service) Stop()

Stop stops the schedule, waits for an enqueue in flight and closes the queue client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL