queue

package
v0.0.0-...-68f839e Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package queue provides a task dispatcher that executes tasks sequentially in a queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher executes Task sequentially in run loop in Serve method.

func NewDispatcher

func NewDispatcher(ctx context.Context) *Dispatcher

NewDispatcher creates a new Dispatcher with the given parent context and options.

func (*Dispatcher) AfterFunc

func (d *Dispatcher) AfterFunc(duration time.Duration, f func()) task.Timer

AfterFunc enqueues f to TaskQueue after specified duration.

func (*Dispatcher) Serve

func (d *Dispatcher) Serve() error

Serve execute Task(s) in loop. The return value of Serve is the error that caused the dispatcher to stop.

NOTE: This method is intended to be called from a single goroutine only. Concurrent calls from multiple goroutines may lead to race conditions.