Documentation
¶
Index ¶
- type Producer
- func (p *Producer) Close() error
- func (p *Producer) IsConnected() bool
- func (p *Producer) Publish(ctx context.Context, taskType string, payload map[string]any) error
- func (p *Producer) PublishAsync(taskType string, payload map[string]any)
- func (p *Producer) PublishWithCustomRoutingKey(ctx context.Context, taskType string, payload map[string]any, ...) error
- func (p *Producer) ServiceName() string
- type ProducerConfig
- type Task
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) IsConnected ¶
IsConnected returns true if the producer has a valid connection
func (*Producer) Publish ¶
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 ¶
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 ¶
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