rabbitmq

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenConnection

func OpenConnection(addr string) (*amqp.Connection, error)

OpenConnection connect to rabbitmq

Types

type Channel

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

Channel data channel

func NewChannel

func NewChannel(conn *amqp.Connection) Channel

NewChannel instance a channel

func (Channel) Create

func (c Channel) Create() (*amqp.Channel, error)

Create create a channel

type Consumer

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

Consumer define consumer for rabbitmq

func NewConsumer

func NewConsumer(addr, exchange string, autoDelete bool) *Consumer

NewConsumer instance a consumer

func (*Consumer) Consume

func (c *Consumer) Consume(ctx context.Context, queueName string, handler Handler) error

func (*Consumer) Handle

func (c *Consumer) Handle(delivery <-chan amqp.Delivery, handler Handler, done chan error)

Handle handle data

func (*Consumer) ReConnect

func (c *Consumer) ReConnect()

ReConnect .

func (*Consumer) Run

func (c *Consumer) Run() error

Run .

func (*Consumer) Start

func (c *Consumer) Start() error

Start start a service

func (*Consumer) Stop

func (c *Consumer) Stop() error

Stop a consumer

type Handler

type Handler func(ctx context.Context, body []byte) error

type Producer

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

Producer define struct for rabbitmq

func NewProducer

func NewProducer(addr, exchange string) *Producer

NewProducer create a producer

func (*Producer) Publish

func (p *Producer) Publish(routingKey, message string) error

Publish push data to queue

func (*Producer) ReConnect

func (p *Producer) ReConnect()

ReConnect .

func (*Producer) Run

func (p *Producer) Run() error

Run .

func (*Producer) Start

func (p *Producer) Start() error

Start start a producer

func (*Producer) Stop

func (p *Producer) Stop()

Stop .

type Queue

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

Queue .

func NewQueue

func NewQueue(channel *amqp.Channel, name string) Queue

NewQueue .

func (Queue) Create

func (q Queue) Create() (amqp.Queue, error)

Create .

type Server

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

func NewServer

func NewServer(addr, exchangeName string) *Server

func (*Server) RegisterSubscriber

func (s *Server) RegisterSubscriber(ctx context.Context, queueName string, h Handler) error

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

type SubscribeOptionMap

type SubscribeOptionMap map[string]Handler

Jump to

Keyboard shortcuts

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