Documentation
¶
Overview ¶
Package rabbitmq preserves the released RabbitMQ adapter import path.
Deprecated: use github.com/faustbrian/go-queue/adapters/rabbitmq.
Index ¶
- Constants
- type DeadLetterConfigdeprecated
- type NativeConfigdeprecated
- type Optiondeprecated
- func WithAddr(value string) Optiondeprecated
- func WithAutoAck(value bool) Optiondeprecated
- func WithDeadLetter(value DeadLetterConfig) Optiondeprecated
- func WithExchangeName(value string) Optiondeprecated
- func WithExchangeType(value string) Optiondeprecated
- func WithLogger(value queue.Logger) Optiondeprecated
- func WithNativeConfig(value NativeConfig) Optiondeprecated
- func WithPublishTimeout(value time.Duration) Optiondeprecated
- func WithQueue(value string) Optiondeprecated
- func WithReconnectConfig(value ReconnectConfig) Optiondeprecated
- func WithRequestTimeout(value time.Duration) Optiondeprecated
- func WithRoutingKey(value string) Optiondeprecated
- func WithRunFunc(value func(context.Context, core.TaskMessage) error) Optiondeprecated
- func WithTag(value string) Optiondeprecated
- type ReconnectConfigdeprecated
- type Workerdeprecated
- func (*Worker) BackendName() string
- func (worker *Worker) Queue(task core.TaskMessage) error
- func (worker *Worker) QueueName() string
- func (worker *Worker) Request() (core.TaskMessage, error)
- func (worker *Worker) Run(ctx context.Context, task core.TaskMessage) error
- func (worker *Worker) Shutdown() error
Examples ¶
Constants ¶
const ( // ExchangeDirect retains the legacy direct exchange name. // // Deprecated: use successor.ExchangeDirect. ExchangeDirect = successor.ExchangeDirect // ExchangeFanout retains the legacy constant; the native adapter rejects it. // // Deprecated: use successor.ExchangeFanout. ExchangeFanout = successor.ExchangeFanout // ExchangeTopic retains the legacy topic exchange name. // // Deprecated: use successor.ExchangeTopic. ExchangeTopic = successor.ExchangeTopic // ExchangeHeaders retains the legacy constant; the native adapter rejects it. // // Deprecated: use successor.ExchangeHeaders. ExchangeHeaders = successor.ExchangeHeaders )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeadLetterConfig
deprecated
type DeadLetterConfig struct {
// Exchange is the terminal exchange.
Exchange string
// Queue is the terminal queue.
Queue string
// RoutingKey is the terminal routing key.
RoutingKey string
// MaxDeliveryAttempts bounds delivery attempts before terminal routing.
MaxDeliveryAttempts uint32
}
DeadLetterConfig preserves the released terminal-route configuration.
Deprecated: use successor.DeadLetterConfig.
type NativeConfig
deprecated
type NativeConfig struct {
// Connection configures the caller-approved native connection.
Connection rabbitmqqueue.ConnectionConfig
// Producer configures confirmed mandatory publication.
Producer rabbitmqqueue.ProducerConfig
// Consumer configures bounded manual-settlement consumption.
Consumer rabbitmqqueue.ConsumerConfig
// MessageID derives stable identity for an outgoing task.
MessageID func(core.TaskMessage) (string, error)
// DeliveryMessageID derives identity for a decoded broker delivery.
DeliveryMessageID func(rabbitmqqueue.Delivery, *job.Message) (string, error)
}
NativeConfig preserves the released explicit RabbitMQ policy boundary.
Deprecated: use successor.NativeConfig.
Example ¶
package main
import (
"context"
"time"
"github.com/faustbrian/go-queue/core"
rabbitmq "github.com/faustbrian/go-queue/rabbitmq"
rabbitmqqueue "github.com/faustbrian/go-rabbitmq-queues"
)
func main() {
credentials := rabbitmqqueue.CredentialProviderFunc(
func(context.Context) (rabbitmqqueue.Credentials, error) {
return rabbitmqqueue.Credentials{Username: "worker", Password: []byte("example-only")}, nil
},
)
_, _ = rabbitmq.NewWorkerE(
rabbitmq.WithNativeConfig(rabbitmq.NativeConfig{
Connection: rabbitmqqueue.ConnectionConfig{
Endpoints: []rabbitmqqueue.Endpoint{{Host: "rabbitmq.internal", Port: 5671}},
VirtualHost: "/", Credentials: credentials,
TLS: rabbitmqqueue.TLSConfig{ServerName: "rabbitmq.internal"},
DialTimeout: 5 * time.Second, Heartbeat: 30 * time.Second,
Recovery: rabbitmqqueue.RecoveryPolicy{
MaxAttempts: 8, InitialDelay: 100 * time.Millisecond, MaxDelay: 5 * time.Second,
},
},
Producer: rabbitmqqueue.ProducerConfig{
Limits: rabbitmqqueue.DefaultLimits(), MaxOutstanding: 256,
PublishTimeout: 5 * time.Second,
},
Consumer: rabbitmqqueue.ConsumerConfig{
Limits: rabbitmqqueue.DefaultLimits(),
Queue: rabbitmqqueue.QueueReference{Name: "jobs", Type: rabbitmqqueue.QueueQuorum},
Name: "jobs-worker", Prefetch: 32, Concurrency: 8,
HandlerTimeout: time.Minute, MaxRequeues: 1,
Failure: rabbitmqqueue.Reject(false),
},
MessageID: func(core.TaskMessage) (string, error) { return "stable-job-id", nil },
}),
rabbitmq.WithQueue("jobs"),
rabbitmq.WithTag("jobs-worker"),
rabbitmq.WithExchangeName("jobs.events"),
rabbitmq.WithExchangeType(rabbitmq.ExchangeTopic),
rabbitmq.WithRoutingKey("jobs.created"),
)
}
Output:
type Option
deprecated
type Option func(*options)
Option preserves the released worker configuration surface.
Deprecated: use successor.Option.
func WithAutoAck
deprecated
func WithDeadLetter
deprecated
func WithDeadLetter(value DeadLetterConfig) Option
WithDeadLetter forwards terminal destination and delivery-attempt policy.
Deprecated: use successor.WithDeadLetter.
func WithExchangeName
deprecated
func WithExchangeType
deprecated
func WithLogger
deprecated
func WithNativeConfig
deprecated
func WithNativeConfig(value NativeConfig) Option
WithNativeConfig forwards explicit native connection and resource policy.
Deprecated: use successor.WithNativeConfig.
func WithPublishTimeout
deprecated
func WithReconnectConfig
deprecated
func WithReconnectConfig(value ReconnectConfig) Option
WithReconnectConfig retains legacy configuration; NativeConfig owns runtime recovery.
Deprecated: use successor.WithReconnectConfig.
func WithRequestTimeout
deprecated
func WithRoutingKey
deprecated
func WithRunFunc
deprecated
type ReconnectConfig
deprecated
type ReconnectConfig struct {
// MaxRetries is retained for source compatibility.
MaxRetries int
// InitialDelay is retained for source compatibility.
InitialDelay time.Duration
// MaxDelay is retained for source compatibility.
MaxDelay time.Duration
}
ReconnectConfig preserves the released source-compatible recovery options. NativeConfig.Connection.Recovery owns runtime recovery.
Deprecated: use successor.ReconnectConfig.
type Worker
deprecated
type Worker struct {
// contains filtered or unexported fields
}
Worker preserves the released queue worker API while delegating all runtime ownership and behavior to the target-oriented successor.
Deprecated: use successor.Worker.
func NewWorkerE
deprecated
NewWorkerE constructs the successor worker and returns its construction error.
Deprecated: use successor.NewWorkerE.
Example ¶
package main
import (
"errors"
"fmt"
queue "github.com/faustbrian/go-queue"
rabbitmq "github.com/faustbrian/go-queue/rabbitmq"
)
func main() {
worker, err := rabbitmq.NewWorkerE()
fmt.Println(worker == nil, errors.Is(err, queue.ErrInvalidConfiguration))
}
Output: true true
func (*Worker) BackendName ¶
BackendName identifies RabbitMQ in lifecycle events.
func (*Worker) Queue ¶
func (worker *Worker) Queue(task core.TaskMessage) error
Queue publishes one mandatory persistent task and waits for broker confirmation.
func (*Worker) Request ¶
func (worker *Worker) Request() (core.TaskMessage, error)
Request returns one decoded task from the bounded delivery bridge.