rabbitmq

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnOption

type ConnOption struct {
	Uri      string // AMQP URI
	Host     string //
	Port     int
	Username string
	Password string
	Vhost    string
}

metadata:

func (*ConnOption) ConnUri

func (m *ConnOption) ConnUri() string

mq uri:

type Consumer

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

func NewConsumer

func NewConsumer(opt *ConnOption) (*Consumer, error)

func (*Consumer) Close

func (m *Consumer) Close()

func (*Consumer) Consume

func (m *Consumer) Consume(exchange *Exchange, queue *Queue, routingKey string, consumerTag string, taskFn TaskFunc) error

批量处理:

func (*Consumer) Get

func (m *Consumer) Get(exchange *Exchange, queue *Queue, routingKey string, consumerTag string, taskFn TaskFunc) error

单条消息处理:

type ConsumerOption

type ConsumerOption struct {
	// meta
	Conn *ConnOption
}

consumer:

type Exchange

type Exchange struct {
	// Exchange name
	Name string

	// Exchange type
	Type string

	// Durable exchanges will survive server restarts
	Durable bool

	// Will remain declared when there are no remaining bindings.
	AutoDelete bool

	// Exchanges declared as `internal` do not accept accept publishing.Internal
	// exchanges are useful for when you wish to implement inter-exchange topologies
	// that should not be exposed to users of the broker.
	Internal bool

	// When noWait is true, declare without waiting for a confirmation from the server.
	NoWait bool

	// amqp.Table of arguments that are specific to the server's implementation of
	// the exchange can be sent for exchange types that require extra parameters.
	Args amqp.Table
}

type Producer

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

func NewProducer

func NewProducer(opt *ConnOption) (*Producer, error)

func (*Producer) Close

func (m *Producer) Close()

func (*Producer) Publish

func (m *Producer) Publish(exchange *Exchange, queue *Queue, routingKey string, message string, reliable bool) error

type ProducerOption

type ProducerOption struct {
	// meta
	Conn *ConnOption

	//
	Exchange *Exchange
	Queue    *Queue

	// The key that when publishing a message to a exchange/queue will be only delivered to
	// given routing key listeners
	RoutingKey string

	// Publishing tag
	Tag string

	// Queue should be on the server/broker
	Mandatory bool

	// Consumer should be bound to server
	Immediate bool

	// Do not wait for a consumer
	NoWait bool

	// App specific data
	Args amqp.Table
}

producer:

type Queue

type Queue struct {
	// The queue name may be empty, in which the server will generate a unique name
	// which will be returned in the Name field of Queue struct.
	Name string

	// Check Exchange comments for durable
	Durable bool

	// Check Exchange comments for auto delete
	AutoDelete bool

	// Exclusive queues are only accessible by the connection that declares them and
	// will be deleted when the connection closes.  Channels on other connections
	// will receive an error when attempting declare, bind, consume, purge or delete a
	// queue with the same name.
	Exclusive bool

	// When noWait is true, the queue will assume to be declared on the server. A
	// channel exception will arrive if the conditions are met for existing queues
	// or attempting to modify an existing queue from a different connection.
	NoWait bool

	// Check Exchange comments for Args
	Args amqp.Table
}

type TaskFunc

type TaskFunc func(message string) error

task handler:

Jump to

Keyboard shortcuts

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