amqptool

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 2 Imported by: 0

README

amqptool

Library to simplify the use of AMQP.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsumeOpt

type ConsumeOpt struct {
	Consumer  string
	AutoAck   bool
	Exclusive bool
	NoLocal   bool
	NoWait    bool
	Args      map[string]interface{}
}

ConsumeOpt contains options for the consumer.

type ExchangeOpt

type ExchangeOpt struct {
	Kind       string
	Durable    bool
	Autodelete bool
	Internal   bool
	NoWait     bool
	Args       map[string]interface{}
}

ExchangeOpt contains options for the exchange.

type QueueOpt

type QueueOpt struct {
	Durable    bool
	AutoDelete bool
	Exclusive  bool
	NoWait     bool
	Args       map[string]interface{}
}

QueueOpt contains options for the queue.

type Receiver

type Receiver struct{}

Receiver contains data for receiving messages from the queue.

func NewReceiver

func NewReceiver(cnn, queue string) *Receiver

NewReceiver create & init the Receiver struct.

type Sender

type Sender struct {
	Cnn             string
	Exchange        string
	ExchangeDeclare bool
	ExchangeOpt     ExchangeOpt
	// contains filtered or unexported fields
}

Sender contains data for sending messages.

func NewSender

func NewSender(cnn, exchange string) *Sender

NewSender create & init the Sender struct.

func (*Sender) Connect

func (s *Sender) Connect() error

Connect creates a connection to the amqp-server and starts the message sending loop.

func (*Sender) NotifyError

func (s *Sender) NotifyError(c chan error) chan error

NotifyError registers a listener for when the server sends a exception.

func (*Sender) Send

func (s *Sender) Send(body []byte, routingKey string) error

Send sends a message to the exchange with a certain key.

type Subscriber

type Subscriber struct {
	Connection    string
	Queue         string
	Exchange      string
	PrefetchCount int
	PassiveMode   bool
	AmqpConfig    *amqp.Config
	QueueOpt      QueueOpt
	ConsumeOpt    ConsumeOpt
}

Subscriber contains data for subscribing to messages from the queue.

func NewSubscriber

func NewSubscriber(cnn, queue string) *Subscriber

NewSubscriber create & init the Subscriber struct.

func (*Subscriber) AddQueueArg

func (s *Subscriber) AddQueueArg(key string, value interface{}) *Subscriber

AddQueueArg add argument to QueueOpt field.

func (*Subscriber) Process

func (s *Subscriber) Process(h func([]byte) error) error

Process starts a message loop.

func (*Subscriber) SetAmqpConfig

func (s *Subscriber) SetAmqpConfig(config amqp.Config) *Subscriber

SetAmqpConfig sets the AmqpConfig

func (*Subscriber) SetExchange

func (s *Subscriber) SetExchange(ex string) *Subscriber

SetExchange set the Exchange field.

func (*Subscriber) SetPassiveMode

func (s *Subscriber) SetPassiveMode(mode bool) *Subscriber

SetPassiveMode sets the Passive Mode status

func (*Subscriber) SetPrefetchCount

func (s *Subscriber) SetPrefetchCount(n int) *Subscriber

SetPrefetchCount set the PrefetchCount field.

Directories

Path Synopsis
examples
send command
subscr command

Jump to

Keyboard shortcuts

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