tasks

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Producer

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

Producer wraps the base queue producer for publishing tasks

func NewProducer

func NewProducer(connConfig queue.ConnectionConfig, config ProducerConfig) (*Producer, error)

NewProducer creates a new task producer

func (*Producer) Close

func (p *Producer) Close() error

Close closes the producer connection

func (*Producer) IsConnected

func (p *Producer) IsConnected() bool

IsConnected returns true if the producer has a valid connection

func (*Producer) Publish

func (p *Producer) Publish(ctx context.Context, taskType string, payload map[string]any) error

Publish publishes a task to the queue with a dynamic routing key The routing key is constructed as "tasks.<taskType>" Example: taskType "email.verify" becomes routing key "tasks.email.verify"

func (*Producer) PublishAsync

func (p *Producer) PublishAsync(taskType string, payload map[string]any)

PublishAsync publishes a task asynchronously (fire and forget)

func (*Producer) PublishWithCustomRoutingKey

func (p *Producer) PublishWithCustomRoutingKey(ctx context.Context, taskType string, payload map[string]any, routingKey string) error

PublishWithCustomRoutingKey publishes a task with a custom routing key Use this if you need to override the default "tasks.<taskType>" pattern

func (*Producer) ServiceName

func (p *Producer) ServiceName() string

ServiceName returns the service name configured for this producer

type ProducerConfig

type ProducerConfig struct {
	// ServiceName is the name of the service publishing tasks
	ServiceName string

	// QueueConfig allows overriding the default queue configuration (optional)
	QueueConfig *queue.Config
}

ProducerConfig holds configuration for the task producer

type Task

type Task struct {
	Service string         `json:"service"`
	Type    string         `json:"type"`
	Payload map[string]any `json:"payload"`
}

Task represents a generic task structure for the tasks queue

Jump to

Keyboard shortcuts

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