rabbitmq

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents the client with connection to RabbitMQ.

func (*Client) Close

func (c *Client) Close()

Close will close the connection.

func (*Client) Ping

func (c *Client) Ping() error

Ping get the status of connection with RabbitMQ

func (*Client) Subscribe

func (c *Client) Subscribe(cg ConsumerConfig, subHandler SubscribeHandler) error

Subscribe subscribe in a queue in exchange to consume events that is published in her. Open a new channel in the client connection. Passing the parameters of name of exchange, type of exchange (direct, topic or fanout), queue name, binding key. And a handler function to execute in consume, where stay the business logic for execute when the event is received.

type ConsumerConfig

type ConsumerConfig struct {
	ExchangeName string
	ExchangeType string // fanout, topic, direct
	QueueName    string
	BindingKey   string
	ConsumerName string
}

ConsumerConfig represents all configs to create and configure a subscribe/consumer

type Message

type Message struct {
	Delivery amqp.Delivery
	Body     []byte
}

Message represents the message/event receive in consumer of RabbitMQ with the body and all fields of delivered message

type RabbitMQ

type RabbitMQ interface {
	Close()
	Ping() error
	Subscribe(cg ConsumerConfig, subHandler SubscribeHandler) error
}

RabbitMQ represents the functions to connect and subribe in RabbitMQ

func New

func New(amqpURI, projectName string) (RabbitMQ, error)

New Connect and returns the AMQP Client that implements the AMQP interface.

type SubscribeHandler

type SubscribeHandler func(ctx context.Context, msg *Message) error

SubscribeHandler signature of func to handler/execute in sub message

Jump to

Keyboard shortcuts

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