rabbitmq

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ConnTimeout = 10 * time.Second

Variables

View Source
var (
	ErrConsumerCanceledByContextError = fmt.Errorf("consumer canceled by context")
	ErrConsumerMessageNotInitialized  = fmt.Errorf("consumer received empty message")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	SetHandler(eventName string, handler EventHandler)
	HandleChannel(ctx context.Context, channelName string, consumerName string, args amqp.Table) error
}

type Config

type Config struct {
	Addr     string    `mapstructure:"addr"`
	Username string    `mapstructure:"username"`
	Password string    `mapstructure:"password"`
	VHost    string    `mapstructure:"vhost"`
	Exchange *Exchange `mapstructure:"exchange"`
}

type Connection

type Connection struct {
	Connection *amqp.Connection
	Channel    *amqp.Channel
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(cfg Config) *Connection

func (*Connection) Close

func (l *Connection) Close(ctx context.Context) (done chan struct{})

func (*Connection) Connect

func (l *Connection) Connect(ctx context.Context)

func (*Connection) CreateConsumer

func (l *Connection) CreateConsumer(
	channelName, consumerName string,
	handler ConsumerHandler,
	args amqp.Table) (*Consumer, error)

type Consumer

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

func (*Consumer) Close

func (l *Consumer) Close() error

func (*Consumer) Handle

func (l *Consumer) Handle(ctx context.Context) error

func (*Consumer) HandleSingleMessage

func (l *Consumer) HandleSingleMessage(ctx context.Context) error

type ConsumerHandler

type ConsumerHandler func(data []byte) (success bool)

type Credentials

type Credentials struct {
	Protocol string
	Username string
	Password string
	Addr     string
	VHost    string
	Exchange *Exchange
}

func (*Credentials) GetURL

func (c *Credentials) GetURL() string

type Event

type Event struct {
	Name       string `json:"name"`
	ID         string `json:"id"`
	SequenceID string `json:"seq"`
	TimeStamp  string `json:"ts"`
	Content    string `json:"content"`
	Persist    string `json:"store"`
	Channel    string `json:"channel"`
}

type EventHandler

type EventHandler func(event Event) error

type Exchange

type Exchange struct {
	Name       string `mapstructure:"name"`
	Type       string `mapstructure:"type"`
	Durable    bool   `mapstructure:"durable"`
	Queue      string `mapstructure:"queue"`
	RoutingKey string `mapstructure:"routing_key"`
}

type IntrvClient

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

func NewClient

func NewClient(connection *Connection, l *logger.Logger) *IntrvClient

func (*IntrvClient) HandleChannel

func (c *IntrvClient) HandleChannel(ctx context.Context, channelName, consumerName string, args amqp.Table) error

func (*IntrvClient) SetDebug

func (c *IntrvClient) SetDebug(debug bool)

func (*IntrvClient) SetHandler

func (c *IntrvClient) SetHandler(eventName string, handler EventHandler)

type Publisher

type Publisher struct {
	Connection *Connection
	Exchange   *Exchange
}

func NewPublisher

func NewPublisher(ctx context.Context, cfg Config) (*Publisher, error)

func (*Publisher) Disconnect

func (p *Publisher) Disconnect() error

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, mes *amqp.Publishing) error

Jump to

Keyboard shortcuts

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