ironmq

package module
v0.0.0-...-7dc0aee Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2013 License: BSD-2-Clause Imports: 12 Imported by: 0

README

DEPRECATED! Please use https://github.com/iron-io/iron_go

IronMQ Go Client

Getting Started

Install the package:

go get github.com/iron-io/iron_mq_go

The API is documented here.

The Basics

Initialize a client and get a queue object:

client := ironmq.NewClient("my project", "my token", ironmq.IronAWSUSEast)
queue := client.Queue("my_queue")

Push a message on the queue:

id, err := queue.Push("Hello, world!")

Pop a message off the queue:

msg, err := queue.Get()

When you pop/get a message from the queue, it will not be deleted. It will eventually go back onto the queue after a timeout if you don't delete it. (The default timeout is 10 minutes.)

Delete a message from the queue:

err := msg.Delete()

Switching Clouds

You can switch to Rackspace by changing the Cloud/Region when creating the client.

client := ironmq.NewClient("my project", "my token", ironmq.IronRackspaceORD)

See cloud.go for full list.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IronAWSUSEast    = NewCloud("https", "mq-aws-us-east-1.iron.io")
	IronRackspaceDFW = NewCloud("https", "mq-rackspace-dfw.iron.io")
	IronRackspaceORD = NewCloud("https", "mq-rackspace-ord.iron.io")
)
View Source
var EmptyQueue = errors.New("queue is empty")

Functions

This section is empty.

Types

type Client

type Client struct {
	Debug bool
	// contains filtered or unexported fields
}

A Client contains an Iron.io project ID and a token for authentication.

func NewClient

func NewClient(projectId, token string, cloud *Cloud) *Client

NewClient returns a new Client using the given project ID and token. The network is not used during this call.

func (*Client) Queue

func (c *Client) Queue(name string) *Queue

Queue returns a Queue using the given name. The network is not used during this call.

type Cloud

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

func NewCloud

func NewCloud(scheme, host string) *Cloud

type Error

type Error struct {
	Status int
	Msg    string
}

func (*Error) Error

func (e *Error) Error() string

type Message

type Message struct {
	Id   string `json:"id,omitempty"`
	Body string `json:"body"`
	// Timeout is the amount of time in seconds allowed for processing the
	// message.
	Timeout int64 `json:"timeout,omitempty"`
	// Delay is the amount of time in seconds to wait before adding the
	// message to the queue.
	Delay int64 `json:"delay,omitempty"`
	// contains filtered or unexported fields
}

func (*Message) Delete

func (m *Message) Delete() error

type Queue

type Queue struct {
	Name   string
	Client *Client
}

Queue represents an IronMQ queue.

func (*Queue) Clear

func (q *Queue) Clear() error

Clear clears all messages from the queue.

func (*Queue) DeleteMsg

func (q *Queue) DeleteMsg(id string) error

func (*Queue) Get

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

Get takes one Message off of the queue. The Message will be returned to the queue if not deleted before the item's timeout.

func (*Queue) Info

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

Info retrieves a QueueInfo structure for the queue.

func (*Queue) Push

func (q *Queue) Push(msg string) (id string, err error)

Push adds a message to the end of the queue using IronMQ's defaults:

timeout - 60 seconds
delay - none

func (*Queue) PushMsg

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

PushMsg adds a message to the end of the queue using the fields of msg as parameters. msg.Id is ignored.

type QueueInfo

type QueueInfo struct {
	Size int // number of items available on the queue
}

QueueInfo provides general information about a queue.

Jump to

Keyboard shortcuts

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