rabbitmq

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

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug bool

Debug debug log flag

Functions

This section is empty.

Types

type AMQPEnv

type AMQPEnv struct {
	User            string `env:"RABBIT_USER" envDefault:"guest"`
	Password        string `env:"RABBIT_PASSWORD" envDefault:"guest"`
	URL             string `env:"RABBIT_URL" envDefault:"localhost"`
	Vhost           string `env:"RABBIT_VHOST" envDefault:""`
	CredentialsFile string `env:"RABBIT_CREDENTIALS_FILE" envDefault:""`
	Protocol        string `env:"RABBIT_PROTOCOL" envDefault:"amqp"`
}

type Channel

type Channel struct {
	*amqp.Channel
	// contains filtered or unexported fields
}

Channel amqp.Channel wapper

func (*Channel) Close

func (ch *Channel) Close() error

Close ensure closed flag set

func (*Channel) Consume

func (ch *Channel) Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error)

Consume wrap amqp.Channel.Consume, the returned delivery will end only when channel closed by developer

func (*Channel) IsClosed

func (ch *Channel) IsClosed() bool

IsClosed indicate closed by developer

type Config

type Config interface {
	GetAMQPEnv() *AMQPEnv
}

type Connection

type Connection struct {
	*amqp.Connection
}

Connection amqp.Connection wrapper

func Dial

func Dial(url string) (*Connection, error)

Dial wrap amqp.Dial, dial and get a reconnect connection

func (*Connection) Channel

func (c *Connection) Channel() (*Channel, error)

Channel wrap amqp.Connection.Channel, get a auto reconnect channel

type RabbitClient

type RabbitClient struct {
	*Connection

	AppName       string
	PublisherMode bool
	// contains filtered or unexported fields
}

func NewRabbitClient

func NewRabbitClient(cfg Config) *RabbitClient

func (*RabbitClient) Close

func (r *RabbitClient) Close() error

func (*RabbitClient) Publisher

func (r *RabbitClient) Publisher(topic string, body []byte) error

func (*RabbitClient) Run

func (r *RabbitClient) Run(ctx context.Context) error

func (*RabbitClient) Subscriber

func (r *RabbitClient) Subscriber(ctx context.Context, topic string, function func([]byte) bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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