Documentation
¶
Index ¶
- type Config
- type MQ
- func (mq *MQ) DeleteQueue() error
- func (mq *MQ) EmptyQueue() error
- func (mq *MQ) Peek() ([]byte, *QueueObject, error)
- func (mq *MQ) Pop() ([]byte, *QueueObject, error)
- func (mq *MQ) PopLast() ([]byte, *QueueObject, error)
- func (mq *MQ) Push(body []byte) (*QueueObject, error)
- func (mq *MQ) PushFirst(body []byte) (*QueueObject, error)
- type QueueObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Address and port number of the Consul endpoint to connect to // EX: 172.16.0.2:8500 // Default is "localhost:8500" Address string `yaml:"address"` // Datacenter is a Consul concept that allows for separating assets. // Consul and ConsulMQ's default is "dc1" Datacenter string `yaml:"datacenter"` // Consul ACL Token // Default is empty (no token) Token string `yaml:"token"` // Unqiue name of the message queue. // Default is "consulmq" MQName string `yaml:"mqname"` // A TTL for messages on the queue. // Default is 10 years (effectively no TTL). // TODO: Enforce TTL's TTL time.Duration }
Config is for passing configuration into the Connect function
type MQ ¶
type MQ struct {
// contains filtered or unexported fields
}
MQ provides methods for manipulating the message queue
func Connect ¶
Connect sets up the connection to the message queue Connect will generate a unique machine ID that persists across restarts and will use this ID to register as a service with Consul.
func (*MQ) DeleteQueue ¶ added in v1.0.5
DeleteQueue deletes an entire queue, leaving nothing intact. You must call Connect after calling DeleteQueue as the configured queue is no longer available.
func (*MQ) EmptyQueue ¶ added in v1.0.5
EmptyQueue empties the contents of a queue but leaves the queue intact
func (*MQ) Pop ¶ added in v1.0.0
func (mq *MQ) Pop() ([]byte, *QueueObject, error)
Pop removes the next object in the queue. Pop returns the message body as bytes and a QueueObject with the object ID, the object's CTime, the TTL deadline, and the message body as bytes.
func (*MQ) PopLast ¶ added in v1.0.0
func (mq *MQ) PopLast() ([]byte, *QueueObject, error)
PopLast removes the last (newest) object in the queue. PopLast returns the message body as bytes and a QueueObject with the object ID, the object's CTime, the TTL deadline, and the message body as bytes.
type QueueObject ¶ added in v1.0.0
type QueueObject struct { // Unique ID of the object ID string // Creation time of the object CreatedAt time.Time // When the object will be deleted TTLDeadline time.Time // Any tags for the object (TBI) // TODO: Implement message tagging Tags []string // The actual data to be put on the queue Body []byte }
QueueObject is a container around any data in the queue