Documentation ¶
Index ¶
- Variables
- func IsDecodeFailure(err error) bool
- type Config
- type Consumer
- type GOBSerializer
- type JSONSerializer
- type Publisher
- type Relay
- func (r *Relay) Broker() broker.Broker
- func (r *Relay) Close() error
- func (r *Relay) Consumer(queue string) (*Consumer, error)
- func (r *Relay) ConsumerWithRoutingKey(queue string, routingKey string) (*Consumer, error)
- func (r *Relay) Publisher(queue string) (*Publisher, error)
- func (r *Relay) PublisherWithRoutingKey(queue string, routingKey string) (*Publisher, error)
- func (r *Relay) RetryBroker(attempts int, min, max time.Duration) (*retryBroker, error)
- type Serializer
Constants ¶
This section is empty.
Variables ¶
var ChannelClosed = fmt.Errorf("Channel closed!")
Returned to indicate a closed channel
var TimedOut = fmt.Errorf("Timeout")
Returned to indicate a read timeout
Functions ¶
func IsDecodeFailure ¶
IsDecodeFailure is a helper to determine if the error returned is a deserialization error.
Types ¶
type Config ¶
type Config struct { Addr string // Host address to dial Port int // Host por to bind Vhost string // Broker Vhost Username string // Broker username Password string // Broker password EnableTLS bool // Broker TLS connection PrefetchCount int // How many messages to prefetch. If < 1, defaults to 1. EnableMultiAck bool // Controls if we allow multi acks DisablePublishConfirm bool // Disables confirmations of publish DisablePersistence bool // Disables message persistence Exchange string // Custom exchange. Defaults to "relay" ExchangeType string // Type of exchange. Defaults to "direct" Serializer Serializer // Defaults to GOBSerializer MessageTTL time.Duration // Optional, attempts to put a TTL on message life QueueTTL time.Duration // Optional, attempts to make a TTL on a queue life WithoutPrefix bool // by default "relay." prefix will be used for legacy support AutoDelete bool // Optional, delete queue for after disconnect, always works for unnamed queues }
Config is passed into New when creating a Relay to tune various parameters around broker interactions.
func ConfigFromURI ¶
ConfigFromURI attempts to parse the given AMQP URI according to the spec and return a relay config based on it. See http://www.rabbitmq.com/uri-spec.html.
Default values for the fields are:
Scheme: amqp Host: localhost Port: 5672 Username: guest Password: guest Vhost: /
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer is a type that is used only for consuming messages from a single queue. Multiple Consumers can multiplex a single relay
func (*Consumer) Ack ¶
Ack will send an acknowledgement to the server that the last message returned by Consume was processed. If EnableMultiAck is true, then all messages up to the last consumed one will be acknowledged
func (*Consumer) Close ¶
Close will shutdown the Consumer. Any messages that are still in flight will be Nack'ed.
func (*Consumer) Consume ¶
Consume will consume the next available message. The message must be acknowledged with Ack() or Nack() before the next call to Consume unless EnableMultiAck is true.
func (*Consumer) ConsumeAck ¶
ConsumeAck will consume the next message and acknowledge that the message has been received. This prevents the message from being redelivered, and no call to Ack() or Nack() is needed.
func (*Consumer) ConsumeTimeout ¶
Consume will consume the next available message or times out waiting. The message must be acknowledged with Ack() or Nack() before the next call to Consume unless EnableMultiAck is true.
type GOBSerializer ¶
type GOBSerializer struct{}
GOBSerializer implements the Serializer interface and uses the GOB format
func (*GOBSerializer) ContentType ¶
func (*GOBSerializer) ContentType() string
func (*GOBSerializer) RelayDecode ¶
func (*GOBSerializer) RelayDecode(r io.Reader, o interface{}) error
func (*GOBSerializer) RelayEncode ¶
func (*GOBSerializer) RelayEncode(w io.Writer, e interface{}) error
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer implements the Serializer interface and uses JSON
func (*JSONSerializer) ContentType ¶
func (*JSONSerializer) ContentType() string
func (*JSONSerializer) RelayDecode ¶
func (*JSONSerializer) RelayDecode(r io.Reader, o interface{}) error
func (*JSONSerializer) RelayEncode ¶
func (*JSONSerializer) RelayEncode(w io.Writer, e interface{}) error
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher is a type that is used only for publishing messages to a single queue. Multiple Publishers can multiplex a single relay
type Relay ¶
func New ¶
New will create a new Relay that can be used to create new publishers or consumers. The caller should no longer modify the configuration once New is invoked, nor should it be shared between multiple relays.
func (*Relay) Close ¶
Close will shutdown the relay. It is best to first Close all the Consumer and Publishers, as this will close the underlying connections.
func (*Relay) Consumer ¶
Consumer will return a new handle that can be used to consume messages from a given queue.
func (*Relay) ConsumerWithRoutingKey ¶
ConsumerWithRoutingKey will return a new handle that can be used to consume messages from a given queue and routing key.
func (*Relay) Publisher ¶
Publisher will return a new handle that can be used to publish messages to the given queue.
func (*Relay) PublisherWithRoutingKey ¶
PublisherWithRoutingKey will return a new handle that can be used to publish messages to the given queue and routing key.