messagequeuecfg

package
v9.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderRedis is used to refer to redis.
	ProviderRedis provider = "redis"
	// ProviderSQS is used to refer to sqs.
	ProviderSQS provider = "sqs"
	// ProviderPubSub is used to refer to GCP Pub/Sub.
	ProviderPubSub provider = "pubsub"
	// ProviderKafka is used to refer to Kafka.
	ProviderKafka provider = "kafka"
	// ProviderNoop discards published messages and consumes nothing. It must be
	// selected deliberately — it is never what an unrecognized provider falls
	// back to.
	ProviderNoop provider = "noop"
)

Variables

View Source
var (
	ErrNilConfig = errors.New("nil config provided")
)

Functions

func NewConsumerProvider

func NewConsumerProvider(ctx context.Context, c *Config, opts ...Option) (messagequeue.ConsumerProvider, error)

NewConsumerProvider provides a ConsumerProvider.

func NewPublisherProvider

func NewPublisherProvider(ctx context.Context, c *Config, opts ...Option) (messagequeue.PublisherProvider, error)

NewPublisherProvider provides a PublisherProvider.

func RegisterMessageQueue

func RegisterMessageQueue(i do.Injector)

RegisterMessageQueue registers both messagequeue.ConsumerProvider and messagequeue.PublisherProvider with the injector.

Types

type Config

type Config struct {
	Consumer  MessageQueueConfig `envPrefix:"CONSUMER_"  json:"consumer,omitzero"  yaml:"consumer,omitempty"`
	Publisher MessageQueueConfig `envPrefix:"PUBLISHER_" json:"publisher,omitzero" yaml:"publisher,omitempty"`
	// contains filtered or unexported fields
}

Config is used to indicate how the messaging provider should be configured.

func (*Config) ValidateWithContext

func (c *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates a Config struct.

type MessageQueueConfig

type MessageQueueConfig struct {
	Kafka    kafka.Config  `envPrefix:"KAFKA_"  json:"kafka,omitzero"     yaml:"kafka,omitempty"`
	Provider provider      `env:"PROVIDER"      json:"provider,omitempty" yaml:"provider,omitempty"`
	SQS      sqs.Config    `envPrefix:"SQS_"    json:"sqs,omitzero"       yaml:"sqs,omitempty"`
	PubSub   pubsub.Config `envPrefix:"PUBSUB_" json:"pubSub,omitzero"    yaml:"pubSub,omitempty"`
	Redis    redis.Config  `envPrefix:"REDIS_"  json:"redis,omitzero"     yaml:"redis,omitempty"`
	// contains filtered or unexported fields
}

MessageQueueConfig is used to indicate how the messaging provider should be configured.

func (*MessageQueueConfig) ValidateWithContext

func (c *MessageQueueConfig) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates a MessageQueueConfig struct.

type Option

type Option func(*options)

Option configures how this package's constructors assemble their providers.

The observability dependencies are options rather than parameters because every one of them is genuinely optional: an absent logger logs nowhere, an absent tracer provider traces nowhere, and an absent metrics provider records nothing. Requiring them positionally made a caller that wanted none of the three name all three anyway, usually as noops.

func WithLogger

func WithLogger(logger logging.Logger) Option

WithLogger attaches a logger. An absent logger logs nowhere.

func WithMetricsProvider

func WithMetricsProvider(metricsProvider metrics.Provider) Option

WithMetricsProvider attaches a metrics provider. An absent provider records nothing.

func WithPillars

func WithPillars(p *observability.Pillars) Option

WithPillars attaches a logger, tracer provider, and metrics provider in one go, for the common case where a caller has already built them together. A nil Pillars attaches nothing.

It is applied in order with the individual options, so a caller can hand over its pillars and then override one of them.

func WithTracerProvider

func WithTracerProvider(tracerProvider tracing.TracerProvider) Option

WithTracerProvider attaches a tracer provider, enabling spans on the instrumented operations. An absent tracer provider traces nowhere.

Jump to

Keyboard shortcuts

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