messageq

package
v0.0.0-...-682f362 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2013 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package messageq provides a reliable pub/sub bus for long term listeners job queuing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArbitraryMessage

type ArbitraryMessage map[string]interface{}

An arbitrary message object that can be directly used by applications

func (ArbitraryMessage) Id

func (t ArbitraryMessage) Id() []byte

type Config

type Config struct {
	*RelyQConfig

	// Subscribers cache decay duration
	SubscriberListDecay time.Duration
}

func (*Config) Defaults

func (cfg *Config) Defaults()

type Discovery

type Discovery interface {
	// Register an endpoint as listening on a channel
	Register(channel, endpoint string) error
	// Unregister an endpoint as listening on a channel
	Unregister(channel, endpiont string) error
	// List subscribers to a channel
	Subscribers(channel string) ([]string, error)

	io.Closer
}

Interface for discovery backend's to implement

type Message

type Message interface {
	relyq.Ider
}

A message in MessageQueue must have the Id() function required by tasks in RelyQueue

type MessageQueue

type MessageQueue struct {
	Errors chan error
	// contains filtered or unexported fields
}

A message queue object.

func New

func New(pool *redis.Pool, disco Discovery, cfg *Config) *MessageQueue

func NewRedis

func NewRedis(pool *redis.Pool, cfg *Config, discoveryPrefix string) *MessageQueue

func (*MessageQueue) Close

func (mq *MessageQueue) Close() error

func (*MessageQueue) Publish

func (mq *MessageQueue) Publish(channel string, message Message) error

Publish a message on a channel

func (*MessageQueue) Subscribe

func (mq *MessageQueue) Subscribe(channel string, example Message) (chan Message, error)

Subscribe on a channel. Returns the channel of messages

func (*MessageQueue) Unsubscribe

func (mq *MessageQueue) Unsubscribe(channel string) error

Unsubscribe from a channel

type RelyQConfig

type RelyQConfig relyq.Config

func (*RelyQConfig) Defaults

func (rqc *RelyQConfig) Defaults()

type StructuredMessage

type StructuredMessage struct {
	MqId string `json:"id"`
}

A struct that implements Ider to be used in message objects for applications. Use like so:

type MyMessage struct {
  StructuredMessage
  OtherFields string
}

func (*StructuredMessage) Id

func (t *StructuredMessage) Id() []byte

Jump to

Keyboard shortcuts

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