Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnqueueOption ¶
type EnqueueOption func(*EnqueueOptions)
EnqueueOption is a functional option for configuring Enqueue.
func WithOnDone ¶
func WithOnDone(onDone func()) EnqueueOption
func WithUnique ¶
func WithUnique() EnqueueOption
WithUnique ensures that the task will not be enqueued if there are more than 1 same task(by string) in the queue.
func WithWait ¶
func WithWait(wg *sync.WaitGroup) EnqueueOption
WithWait specifies a WaitGroup to track task completion.
type EnqueueOptions ¶
type EnqueueOptions struct {
// contains filtered or unexported fields
}
EnqueueOptions configures task enqueuing behavior.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages a set of named task queues. It provides methods to enqueue tasks, stop individual queues, or stop all queues.
func NewService ¶
NewService creates a new Service with the given context. The context is used for all queues created by the Service.
func (*Service) Enqueue ¶
Enqueue adds a task to the specified queue, creating and starting the queue if it doesn't exist. It ensures thread-safety using a mutex and propagates the Service's context to the queue.
Context Hierarchy: - ctx: Task-specific context for cascade cancellation (e.g., parent task context) - w.ctx: Service-level context for lifecycle management (queue shutdown) The queue uses w.ctx for its processing loop, but individual tasks use their own ctx.