rabbitmq

package module
v0.0.0-...-3ff7a9a Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

rabbitmq

Usage see:

/rabbitmq_test.go

type RabbitMQ interface {
	// dial rabbit and init queue with exchange and queuebind.
	Dial() error
	// publish message.
	// header spec for queue with header exchange, default x-match: all.
	Publish(body []byte, exchangeName, routingKey string, header ...map[string]interface{}) error
	// subscribe operation occur error will finish
	// and
	// will block until ack & nack occured error or context was canceled
	Consume(ctx context.Context, queueName, consumerName string, consumer ConsumeFunc)
	// return the subscribe operation occured error or ack & nack error.
	ConsumeDone() <-chan error
}

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type ConsumeFunc

type ConsumeFunc func(ctx context.Context, data []byte) (requeue bool)

type ExchangeType

type ExchangeType string
const (
	ExchangeType_Topic  ExchangeType = amqp.ExchangeTopic
	ExchangeType_Direct ExchangeType = amqp.ExchangeDirect
	ExchangeType_Fanout ExchangeType = amqp.ExchangeFanout
	ExchangeType_Header ExchangeType = amqp.ExchangeHeaders
)

func ValidateExchangeType

func ValidateExchangeType(exchangeType string) (ExchangeType, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func InitQueueOption

func InitQueueOption(exchangeName string, exchangeType ExchangeType, bindingKey, queueName string, header map[string]interface{}) Option

func KeepliveOption

func KeepliveOption(duration time.Duration) Option

type RabbitMQ

type RabbitMQ interface {
	// dial rabbit and init queue with exchange and queuebind.
	Dial() error
	// publish message.
	// header spec for queue with header exchange, default x-match: all.
	Publish(body []byte, exchangeName, routingKey string, header ...map[string]interface{}) error
	// subscribe operation occur error will finish
	// and
	// will block until ack & nack occured error or context was canceled
	Consume(ctx context.Context, queueName, consumerName string, consumer ConsumeFunc)
	// return the subscribe operation occured error or ack & nack error.
	ConsumeDone() <-chan error
}

func NewRabbitMQ

func NewRabbitMQ(username, password, ip string, port uint, vhost string, opts ...Option) RabbitMQ

Jump to

Keyboard shortcuts

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