rabbit

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

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

func NewConnector

func NewConnector(cfg ConnectorConfig) *Connector

func (*Connector) GetName

func (c *Connector) GetName() string

func (*Connector) Start

func (c *Connector) Start(ctx context.Context) (err error)

func (*Connector) Stop

func (c *Connector) Stop(_ context.Context) (err error)

type ConnectorConfig

type ConnectorConfig struct {
	Name                 string `validate:"required"`
	ReconnectionAttempts int    `validate:"required,min=1"`
	URI                  struct {
		Host     string `validate:"required"`
		Port     int    `validate:"required,min=0"`
		Username string `validate:"required"`
		Password string `validate:"required"`
		Vhost    string `validate:"required"`

		CertFile   string // client TLS auth - path to certificate (PEM)
		CACertFile string // client TLS auth - path to CA certificate (PEM)
		KeyFile    string // client TLS auth - path to private key (PEM)
		ServerName string // client TLS auth - server name
	} `validate:"required"`

	Exchange         string
	UseDurableQueues bool
}

type Consumer

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

func NewConsumer

func NewConsumer(cfg ConnectorConfig) *Consumer

func (*Consumer) AddSubscriber

func (c *Consumer) AddSubscriber(queueName string, handler NotificationHandler)

func (*Consumer) GetName

func (c *Consumer) GetName() string

func (*Consumer) Start

func (c *Consumer) Start(ctx context.Context) (err error)

func (*Consumer) Stop

func (c *Consumer) Stop(ctx context.Context) (err error)

type NotificationHandler

type NotificationHandler func(context.Context, amqp.Delivery)

func NewHandler

func NewHandler[T any](
	handler func(context.Context, *T) error,
) NotificationHandler

type Publisher

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

func NewPublisher

func NewPublisher(cfg ConnectorConfig) *Publisher

func (*Publisher) GetName

func (c *Publisher) GetName() string

func (*Publisher) Publish

func (c *Publisher) Publish(ctx context.Context, queueName string, data any) error

func (*Publisher) Start

func (c *Publisher) Start(ctx context.Context) (err error)

func (*Publisher) Stop

func (c *Publisher) Stop(ctx context.Context) (err error)

Jump to

Keyboard shortcuts

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