pubsub

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Closer

type Closer interface {
	// Close closes the AMQP connection and channel(s).
	//
	// This SHOULD be called, AMQP 0-9-1 asks for gracefully closing connections.
	// https://www.rabbitmq.com/tutorials/amqp-concepts.html#amqp-connections
	// Channels close with their connection.
	//
	// TODO(ilazakis): test we close on cleanup (worker, progress, api)
	Close() error
}

Closer closes a pub/sub connection. Safe to call multiple times.

type Publisher

type Publisher interface {
	Closer
	// Publish publishes an event to the `Publisher`'s exchange.
	// Events are marshaled into `JSON` before publishing.
	Publish(msg interface{}, routingKey string) error
}

A Publisher publishes messages/events of arbitrary type. to its exhange under the provided routing key.

type RabbitMQ

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

RabbitMQ `Client` implementation.

func NewRabbitMQ

func NewRabbitMQ(exchange, user, pass, host string, port int64, retryInterval time.Duration) (*RabbitMQ, error)

NewRabbitMQ - RabbitMQ client initializer.

func (*RabbitMQ) Close

func (c *RabbitMQ) Close() error

Close closes the Rabbit MQ connection and channel(s).

This SHOULD be called, AMQP 0-9-1 asks for gracefully closing connections. https://www.rabbitmq.com/tutorials/amqp-concepts.html#amqp-connections Channels close with their connection.

TODO(ilazakis): test to verify we close on cleanup.

func (*RabbitMQ) Publish

func (c *RabbitMQ) Publish(msg interface{}, routingKey string) error

Publish publishes a message to `Client`'s exchange.

func (*RabbitMQ) Subscribe

func (c *RabbitMQ) Subscribe(queue, routingKey string, prefetchCount int, messageCallback func(body []byte, ack func(ok bool, requeue bool))) error

Subscribe declares the queue and binds the queue/routing key pair to an exchange.

Use the messageCallback function to handle and ack the message.

type Subscriber

type Subscriber interface {
	Closer
	// Subscribe declares the queue and binds the queue/routing key pair to an exchange.
	//
	// Use the messageCallback function to handle and ack incoming messages.
	Subscribe(queue, routingKey string, prefetchCount int, messageCallback func(body []byte, ack func(ok bool, requeue bool))) error
}

A Subscriber listens for messages/events.

Jump to

Keyboard shortcuts

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