rabbit

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: MIT Imports: 8 Imported by: 0

README

Rabbit

基于github.com/streadway/amqp,RabbitMQ 访问简单封装

Documentation

Index

Constants

View Source
const (
	HeaderAttempt = "Rabbit-Attempt"
)

Variables

View Source
var (
	ErrNotConnected    = errors.New("not connected to a server")
	ErrChanneleInvalid = errors.New("channel is invalid")
	ErrAlreadyClosed   = errors.New("already closed: not connected to the server")
	ErrShutdown        = errors.New("session is shutting down")
)

Functions

This section is empty.

Types

type Consumer

type Consumer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(manager *Manager, exchange *Exchange, queue *Queue) *Consumer

func (*Consumer) Close

func (c *Consumer) Close()

func (*Consumer) Do

func (c *Consumer) Do(id string, handle HandleFunc) error

func (*Consumer) IsReady

func (c *Consumer) IsReady() bool

type Exchange

type Exchange struct {
	Name        string
	Type        string
	Durable     bool
	AutoDeleted bool
	Internal    bool
	NoWait      bool
	Args        amqp.Table
}

type HandleFunc

type HandleFunc func(ctx context.Context, message Message) bool

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager(addr string, logger *logrus.Logger) *Manager

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) IsReady

func (m *Manager) IsReady() bool

func (*Manager) NewConsumer

func (m *Manager) NewConsumer(exchange *Exchange, queue *Queue) *Consumer

func (*Manager) NewPublisher

func (m *Manager) NewPublisher(exchange *Exchange, delay int) *Publisher

type Message

type Message struct {
	ID          string
	Body        []byte
	ContentType string
	RoutingKey  string
	Attempt     int
}

func BuildMessage

func BuildMessage(d amqp.Delivery) Message

type Publisher

type Publisher struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewPublisher

func NewPublisher(manager *Manager, ex *Exchange, delay int) *Publisher

func (*Publisher) Close

func (p *Publisher) Close()

func (*Publisher) IsReady

func (p *Publisher) IsReady() bool

func (*Publisher) PublicWithACK

func (p *Publisher) PublicWithACK(message *Message) error

func (*Publisher) Publish

func (p *Publisher) Publish(message *Message) error

type Queue

type Queue struct {
	Name        string
	Durable     bool
	AutoDeleted bool
	Exclusive   bool
	NoWait      bool
	Args        amqp.Table

	RoutingKey    string
	PrefetchCount int
}

Jump to

Keyboard shortcuts

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