rabbitmq

package
v0.0.0-...-1b39580 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConsumerCanceledByContextError = fmt.Errorf("consumer canceled by context")
View Source
var ConsumerMessageNotInitialized = 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() error

func (*Connection) Connect

func (l *Connection) Connect() error

func (*Connection) CreateConsumer

func (l *Connection) CreateConsumer(channelName string, 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
}

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) *IntrvClient

func (*IntrvClient) HandleChannel

func (c *IntrvClient) HandleChannel(ctx context.Context, channelName string, 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(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