Documentation
¶
Index ¶
- type Manager
- func (self *Manager) CleanQueue(ctx context.Context, name string) (result []schema.Task, err error)
- func (self *Manager) CreateNextPartition(ctx context.Context) (result string, err error)
- func (self *Manager) CreatePartition(ctx context.Context, meta schema.PartitionMeta) (err error)
- func (self *Manager) CreateTask(ctx context.Context, queue string, meta schema.TaskMeta) (result *schema.Task, err error)
- func (self *Manager) DeletePartition(ctx context.Context, name string) (err error)
- func (self *Manager) DeleteQueue(ctx context.Context, name string) (result *schema.Queue, err error)
- func (self *Manager) DeleteTicker(ctx context.Context, name string) (result *schema.Ticker, err error)
- func (self *Manager) DropDrainedPartition(ctx context.Context) (result string, err error)
- func (self *Manager) GetPartitionSeq(ctx context.Context) (result uint64, err error)
- func (self *Manager) GetQueue(ctx context.Context, name string) (result *schema.QueueWithStatus, err error)
- func (self *Manager) GetTask(ctx context.Context, id uint64) (result *schema.TaskWithStatus, err error)
- func (self *Manager) GetTicker(ctx context.Context, name string) (result *schema.Ticker, err error)
- func (self *Manager) ListPartitions(ctx context.Context) (result []schema.Partition, err error)
- func (self *Manager) ListQueueStatuses(ctx context.Context) (result []schema.QueueWithStatus, err error)
- func (self *Manager) ListQueues(ctx context.Context, req schema.QueueListRequest) (result *schema.QueueList, err error)
- func (self *Manager) ListTasks(ctx context.Context, req schema.TaskListRequest) (result *schema.TaskList, err error)
- func (self *Manager) ListTickers(ctx context.Context, req schema.TickerListRequest) (result *schema.TickerList, err error)
- func (self *Manager) NextTask(ctx context.Context, worker string, queues ...string) (result *schema.Task, err error)
- func (self *Manager) NextTicker(ctx context.Context) (result *schema.Ticker, err error)
- func (self *Manager) RegisterQueue(ctx context.Context, name string, meta schema.QueueMeta, ...) (result *schema.Queue, err error)
- func (self *Manager) RegisterTicker(ctx context.Context, name string, meta schema.TickerMeta, ...) (resultPtr *schema.Ticker, err error)
- func (self *Manager) ReleaseTask(ctx context.Context, taskId uint64, success bool, result json.RawMessage, ...) (resp *schema.Task, err error)
- func (self *Manager) Run(ctx context.Context, logger *slog.Logger) error
- func (self *Manager) Running() bool
- func (self *Manager) UnregisterQueue(ctx context.Context, name string) (err error)
- func (self *Manager) UpdateQueue(ctx context.Context, name string, meta schema.QueueMeta) (result *schema.Queue, err error)
- func (self *Manager) UpdateTicker(ctx context.Context, name string, meta schema.TickerMeta) (result *schema.Ticker, err error)
- type Opt
- func WithMaintenancePeriod(period time.Duration) Opt
- func WithMeter(meter metric.Meter) Opt
- func WithPartitionAhead(ahead uint64) Opt
- func WithPartitionSize(size uint64) Opt
- func WithPartitionThreshold(threshold float64) Opt
- func WithRetention(retention time.Duration) Opt
- func WithSchema(schemaName string) Opt
- func WithTracer(tracer trace.Tracer) Opt
- func WithWorker(workerName string) Opt
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
func (*Manager) CleanQueue ¶
CleanQueue removes up to schema.QueueCleanLimit of the queue's finished tasks, which finished longer ago than the retention period, and returns the tasks removed.
func (*Manager) CreateNextPartition ¶
func (*Manager) CreatePartition ¶
func (*Manager) CreateTask ¶
func (self *Manager) CreateTask(ctx context.Context, queue string, meta schema.TaskMeta) (result *schema.Task, err error)
CreateTask creates a new task in a queue, and returns it.
func (*Manager) DeletePartition ¶
func (*Manager) DeleteQueue ¶
func (self *Manager) DeleteQueue(ctx context.Context, name string) (result *schema.Queue, err error)
DeleteQueue deletes an existing queue, and returns it.
func (*Manager) DeleteTicker ¶
func (self *Manager) DeleteTicker(ctx context.Context, name string) (result *schema.Ticker, err error)
DeleteTicker deletes an existing ticker, and returns the deleted ticker.
func (*Manager) DropDrainedPartition ¶
func (*Manager) GetPartitionSeq ¶
func (*Manager) GetQueue ¶
func (self *Manager) GetQueue(ctx context.Context, name string) (result *schema.QueueWithStatus, err error)
GetQueue returns a queue by name.
func (*Manager) GetTask ¶ added in v1.4.3
func (self *Manager) GetTask(ctx context.Context, id uint64) (result *schema.TaskWithStatus, err error)
GetTask returns a task with its status, so it can be examined. The task isn't retained or changed.
func (*Manager) ListPartitions ¶
func (*Manager) ListQueueStatuses ¶
func (self *Manager) ListQueueStatuses(ctx context.Context) (result []schema.QueueWithStatus, err error)
ListQueueStatuses returns every queue, with the number of its tasks with each status
func (*Manager) ListQueues ¶
func (self *Manager) ListQueues(ctx context.Context, req schema.QueueListRequest) (result *schema.QueueList, err error)
ListQueues returns all queues as a list.
func (*Manager) ListTasks ¶
func (self *Manager) ListTasks(ctx context.Context, req schema.TaskListRequest) (result *schema.TaskList, err error)
ListTasks returns all tasks with optional queue and status filtering.
func (*Manager) ListTickers ¶
func (self *Manager) ListTickers(ctx context.Context, req schema.TickerListRequest) (result *schema.TickerList, err error)
ListTickers returns all tickers as a list.
func (*Manager) NextTask ¶
func (self *Manager) NextTask(ctx context.Context, worker string, queues ...string) (result *schema.Task, err error)
NextTask retains a task from any of the specified queues, and returns it. If no task is available, nil is returned.
func (*Manager) NextTicker ¶
NextTicker returns the next due ticker of the tickers with callbacks in this process, and marks it as run now, or returns nil if none is due. The tickers of another process sharing the database aren't returned.
func (*Manager) RegisterQueue ¶
func (self *Manager) RegisterQueue(ctx context.Context, name string, meta schema.QueueMeta, callback schema.TaskFunc) (result *schema.Queue, err error)
RegisterQueue creates a new queue, or updates an existing queue, and returns it.
func (*Manager) RegisterTicker ¶
func (self *Manager) RegisterTicker(ctx context.Context, name string, meta schema.TickerMeta, callback schema.TaskFunc) (resultPtr *schema.Ticker, err error)
RegisterTicker creates a new ticker, or updates an existing ticker, and returns it.
func (*Manager) ReleaseTask ¶
func (self *Manager) ReleaseTask(ctx context.Context, taskId uint64, success bool, result json.RawMessage, status *string) (resp *schema.Task, err error)
ReleaseTask releases a task, optionally marking it as failed, and returns it.
func (*Manager) Run ¶
Run runs the event loop until the context is cancelled, running the tasks of the queues, and the tickers, which have callbacks in this process. The queues and tickers of another process sharing the database are left to that process. When the context is cancelled, the running tasks are cancelled, and released as failed, so they're retried, if they have retries left. Only one event loop can run at a time.
func (*Manager) Running ¶
Running reports whether the event loop is running, and listening for new tasks, so a task created afterwards is run straight away
func (*Manager) UnregisterQueue ¶ added in v1.4.1
UnregisterQueue removes the task callback of the queue in this process, so this process stops running its tasks, but keeps the queue and its tasks, for other processes, or for when the queue is registered again. Tasks which are running are released when they finish. Returns ErrNotFound if the queue has no callback in this process.
type Opt ¶
type Opt func(*opt) error
Opt configures a Manager during construction.
func WithMaintenancePeriod ¶
WithMaintenancePeriod sets how often the maintenance ticker runs. Values less than 1 second are ignored.
func WithPartitionAhead ¶
WithPartitionAhead sets how many partitions to create when threshold is reached.
func WithPartitionSize ¶
WithPartitionSize sets the task partition size. Values less than 1 are ignored.
func WithPartitionThreshold ¶
WithPartitionThreshold sets the partition creation threshold in the range (0,1].
func WithRetention ¶
WithRetention sets how long finished tasks are kept, before the cleanup ticker deletes them. Zero deletes them when the ticker next runs, and negative values are ignored.
func WithSchema ¶
WithSchema sets the database schema names to use for all queries. If not set the default schemas are used.
func WithTracer ¶
WithTracer sets the OpenTelemetry tracer used for manager spans.
func WithWorker ¶
WithWorker sets the worker name used for manager tasks. If not set the hostname is used.