mq

package
v0.0.0-...-97b4fb6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

IronMQ (elastic message queue) client library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrQueueNotFound

func ErrQueueNotFound(err error) bool

Types

type Alert

type Alert struct {
	Type      string `json:"type"`
	Trigger   int    `json:"trigger"`
	Direction string `json:"direction"`
	Queue     string `json:"queue"`
	Snooze    int    `json:"snooze"`
}

type Message

type Message struct {
	Id            string    `json:"id,omitempty"`
	Body          string    `json:"body"`
	Delay         int64     `json:"delay,omitempty"` // time in seconds to wait before enqueue, default 0
	ReservedUntil time.Time `json:"reserved_until,omitempty"`
	ReservedCount int       `json:"reserved_count,omitempty"`
	ReservationId string    `json:"reservation_id,omitempty"`
	// contains filtered or unexported fields
}

Message is dual purpose, as it represents a returned message and also can be used for creation. For creation, only Body and Delay are valid. Delay will not be present in returned message.

func (Message) Delete

func (m Message) Delete() (err error)

Delete message from queue

func (Message) Release

func (m Message) Release(delay int64) (err error)

Put message back in the queue, message will be available after +delay+ seconds.

func (Message) Subscribers

func (m Message) Subscribers() (interface{}, error)

func (*Message) Touch

func (m *Message) Touch() (err error)

Reset timeout of message to keep it reserved

func (*Message) TouchFor

func (m *Message) TouchFor(timeout int) (err error)

Reset timeout of message to keep it reserved

type PushInfo

type PushInfo struct {
	RetriesDelay int               `json:"retries_delay,omitempty"`
	Retries      int               `json:"retries,omitempty"`
	Subscribers  []QueueSubscriber `json:"subscribers,omitempty"`
	ErrorQueue   string            `json:"error_queue,omitempty"`
}

type PushStatus

type PushStatus struct {
	Retried    int    `json:"retried"`
	StatusCode int    `json:"status_code"`
	Status     string `json:"status"`
}

type Queue

type Queue struct {
	Settings config.Settings `json:"-"`
	Name     string          `json:"name"`
}

A Queue is the client's idea of a queue, sufficient for getting information for the queue with given Name at the server configured with Settings. See mq.New()

func ConfigNew

func ConfigNew(queueName string, settings *config.Settings) Queue

ConfigNew uses the specified settings over configuration specified in an iron.json file or environment variables to return a Queue object capable of acquiring information about or modifying the queue specified by queueName.

func Filter

func Filter(prefix string) ([]Queue, error)

Filter is like List, but will only return queues with the specified prefix.

func FilterPage

func FilterPage(prefix, prev string, perPage int) ([]Queue, error)

Like ListPage, but with an added filter.

func List

func List() ([]Queue, error)

List will get a listQueues of all queues for the configured project, paginated 30 at a time. For paging or filtering, see ListPage and Filter.

func ListPage

func ListPage(prev string, perPage int) ([]Queue, error)

ListPage is like List, but will allow specifying a page length and pagination. To get the first page, let prev = "". To get the second page, use the name of the last queue on the first page as "prev".

func ListQueues

func ListQueues(s config.Settings, prefix, prev string, perPage int) ([]Queue, error)

func New

func New(queueName string) Queue

New uses the configuration specified in an iron.json file or environment variables to return a Queue object capable of acquiring information about or modifying the queue specified by queueName.

func (Queue) AddAlerts

func (q Queue) AddAlerts(alerts ...*Alert) (err error)

func (Queue) AddSubscribers

func (q Queue) AddSubscribers(subscribers ...QueueSubscriber) error

func (Queue) Clear

func (q Queue) Clear() (err error)

Delete all messages in the queue

func (Queue) Delete

func (q Queue) Delete() error

func (Queue) DeleteMessage

func (q Queue) DeleteMessage(msgId, reservationId string) (err error)

Delete message from queue

func (Queue) DeleteMessages

func (q Queue) DeleteMessages(ids []string) error

Delete multiple messages by id

func (Queue) DeleteReservedMessages

func (q Queue) DeleteReservedMessages(messages []Message) error

Delete multiple reserved messages from the queue

func (Queue) Get

func (q Queue) Get() (msg *Message, err error)

Get reserves a message from the queue. Deprecated, use Reserve instead.

func (Queue) GetN

func (q Queue) GetN(n int) ([]Message, error)

GetN is Get for N. Deprecated, use ReserveN instead.

func (Queue) GetNWithTimeout

func (q Queue) GetNWithTimeout(n, timeout int) ([]Message, error)

TODO deprecate for LongPoll?

func (Queue) Info

func (q Queue) Info() (QueueInfo, error)

Will return information about a queue, could also be used to check existence. TODO make QueueNotExist err

func (Queue) LongPoll

func (q Queue) LongPoll(n, timeout, wait int, delete bool) ([]Message, error)

LongPoll is the long form for Get, Pop, with all options available. If wait = 0, then LongPoll is simply a get, otherwise, the server will poll for n messages up to wait seconds (max 30). If delete is specified, then each message will be deleted instead of being put back onto the queue.

func (Queue) MessageSubscribers

func (q Queue) MessageSubscribers(msgId string) ([]Subscriber, error)

func (Queue) MessageSubscribersPollN

func (q Queue) MessageSubscribersPollN(msgId string, n int) ([]Subscriber, error)

func (Queue) Peek

func (q Queue) Peek() ([]Message, error)

Peek first 30 messages on queue.

func (Queue) PeekN

func (q Queue) PeekN(n int) ([]Message, error)

Peek with N, max 100.

func (Queue) Pop

func (q Queue) Pop() (msg Message, err error)

Pop will get and delete a message from the queue.

func (Queue) PopN

func (q Queue) PopN(n int) ([]Message, error)

PopN is Pop for N.

func (Queue) PushMessage

func (q Queue) PushMessage(msg Message) (id string, err error)

PushMessage enqueues a message.

func (Queue) PushMessages

func (q Queue) PushMessages(msgs ...Message) (ids []string, err error)

PushMessages enqueues each message in order.

func (Queue) PushString

func (q Queue) PushString(body string) (id string, err error)

PushString enqueues a message with body specified and no delay.

func (Queue) PushStrings

func (q Queue) PushStrings(bodies ...string) (ids []string, err error)

PushStrings enqueues messages with specified bodies and no delay.

func (Queue) ReleaseMessage

func (q Queue) ReleaseMessage(msgId, reservationId string, delay int64) (err error)

Put message back in the queue, message will be available after +delay+ seconds.

func (Queue) RemoveSubscribers

func (q Queue) RemoveSubscribers(subscribers ...string) error

func (Queue) RemoveSubscribersCollection

func (q Queue) RemoveSubscribersCollection(subscribers ...QueueSubscriber) error

func (Queue) ReplaceSubscribers

func (q Queue) ReplaceSubscribers(subscribers ...QueueSubscriber) error

func (Queue) Reserve

func (q Queue) Reserve() (msg *Message, err error)

func (Queue) ReserveN

func (q Queue) ReserveN(n int) ([]Message, error)

ReserveN reserves multiple messages from the queue.

func (Queue) TouchMessage

func (q Queue) TouchMessage(msgId, reservationId string) (string, error)

Reset timeout of message to keep it reserved

func (Queue) TouchMessageFor

func (q Queue) TouchMessageFor(msgId, reservationId string, timeout int) (string, error)

Reset timeout of message to keep it reserved

func (*Queue) UnmarshalJSON

func (q *Queue) UnmarshalJSON(data []byte) error

func (Queue) Update

func (q Queue) Update(queueInfo QueueInfo) (QueueInfo, error)

Will create or update a queue, all QueueInfo fields are optional. Queue type cannot be changed.

type QueueInfo

type QueueInfo struct {
	Name string `json:"name"`

	Size          int `json:"size"`
	TotalMessages int `json:"total_messages"`

	MessageExpiration int       `json:"message_expiration"`
	MessageTimeout    int       `json:"message_timeout"`
	Type              string    `json:"type,omitempty"`
	Push              *PushInfo `json:"push,omitempty"`
	Alerts            []Alert   `json:"alerts,omitempty"`
}

When used for create/update, Size and TotalMessages will be omitted.

func ConfigCreateQueue

func ConfigCreateQueue(queueInfo QueueInfo, settings *config.Settings) (QueueInfo, error)

Will create a new queue, all fields are optional. Queue type cannot be changed.

func CreateQueue

func CreateQueue(queueName string, queueInfo QueueInfo) (QueueInfo, error)

Will create a new queue, all fields are optional. Queue type cannot be changed.

type QueueSubscriber

type QueueSubscriber struct {
	Name    string            `json:"name"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers,omitempty"` // HTTP headers
}

type Subscriber

type Subscriber struct {
	Retried    int    `json:"retried"`
	StatusCode int    `json:"status_code"`
	Status     string `json:"status"`
	URL        string `json:"url"`
}

type Subscription

type Subscription struct {
	PushType     string
	Retries      int
	RetriesDelay int
}

type Timestamped

type Timestamped struct {
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Jump to

Keyboard shortcuts

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