mqs

package
v0.0.0-...-5571336 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2015 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TinyMQSErrNamespace = "MQS"
)

Variables

View Source
var (
	ErrDecodeBodyFailed          = errors.TN(TinyMQSErrNamespace, 1, "decode body failed, {{.err}}, body: \"{{.body}}\"")
	ErrGetBodyDecodeElementError = errors.TN(TinyMQSErrNamespace, 2, "get body decode element error, local: {{.local}}, error: {{.err}}")
	ErrQueueNotExist             = errors.TN(TinyMQSErrNamespace, 3, "queue not exist, queue: {{.queueName}}")
	ErrNoMessage                 = errors.TN(TinyMQSErrNamespace, 4, "message not exist, queue: {{.queueName}}")
	ErrInternalError             = errors.TN(TinyMQSErrNamespace, 5, "Internal error, error: {{.err}}")
	ErrBadReceiptHandle          = errors.TN(TinyMQSErrNamespace, 6, "The receipt handle you provide is not valid. {{.handle}}")
	ErrOwnerIDIsEmpty            = errors.TN(TinyMQSErrNamespace, 7, "owner id is empty")
	ErrQueueNameIsEmpty          = errors.TN(TinyMQSErrNamespace, 8, "queue name is empty, owner: {{.ownerID}}")
	ErrHostIsEmpty               = errors.TN(TinyMQSErrNamespace, 9, "host is empty for pool owner: {{.ownerID}}")
	ErrPoolAlreadyExist          = errors.TN(TinyMQSErrNamespace, 10, "pool already exist, owner: {{.ownerID}}")
	ErrPoolNotExist              = errors.TN(TinyMQSErrNamespace, 11, "host did not have related pool")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	OwnerId         string
	AccessKeyId     string
	AccessKeySecret string
}

type Base64Bytes

type Base64Bytes []byte

func (Base64Bytes) MarshalXML

func (p Base64Bytes) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Base64Bytes) UnmarshalXML

func (p *Base64Bytes) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)

type BatchMessageReceiveResponse

type BatchMessageReceiveResponse struct {
	XMLName  xml.Name                 `xml:"Messages" json:"-"`
	Messages []MessageReceiveResponse `xml:"Message" json:"messages"`
}

type BatchMessageSendRequest

type BatchMessageSendRequest struct {
	XMLName  xml.Name             `xml:"Messages"`
	Messages []MessageSendRequest `xml:"Message"`
}

type CreateQueueRequest

type CreateQueueRequest struct {
	XMLName                xml.Name `xml:"Queue" json:"-"`
	DelaySeconds           int32    `xml:"DelaySenconds,omitempty" json:"delay_senconds,omitempty"`
	MaxMessageSize         int32    `xml:"MaximumMessageSize,omitempty" json:"maximum_message_size,omitempty"`
	MessageRetentionPeriod int32    `xml:"MessageRetentionPeriod,omitempty" json:"message_retention_period,omitempty"`
	VisibilityTimeout      int32    `xml:"VisibilityTimeout,omitempty" json:"visibility_timeout,omitempty"`
	PollingWaitSeconds     int32    `xml:"PollingWaitSeconds,omitempty" json:"polling_wait_secods,omitempty"`
}

type ErrorMessageResponse

type ErrorMessageResponse struct {
	XMLName   xml.Name `xml:"Error" json:"-"`
	Code      string   `xml:"Code,omitempty" json:"code,omitempty"`
	Message   string   `xml:"Message,omitempty" json:"message,omitempty"`
	RequestId string   `xml:"RequestId,omitempty" json:"request_id,omitempty"`
	HostId    string   `xml:"HostId,omitempty" json:"host_id,omitempty"`
}

type HTTPConfig

type HTTPConfig struct {
	Address string `json:"address"`
}

type MessagePool

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

func NewMessagePool

func NewMessagePool(poolMode MessagePoolMode, queuesProperties ...QueueProperty) *MessagePool

func (*MessagePool) Delete

func (p *MessagePool) Delete(queueName string, receiptHandle string) (err error)

func (*MessagePool) Dequeue

func (p *MessagePool) Dequeue(queueName string) (message TinyQueueMessage, err error)

func (*MessagePool) Enqueue

func (p *MessagePool) Enqueue(queueName string, delaySeconds time.Duration, priority int64, body Base64Bytes) (id string, err error)

func (*MessagePool) GetQueueProperty

func (p *MessagePool) GetQueueProperty(queueName string) (property QueueProperty, err error)

type MessagePoolMode

type MessagePoolMode int32
const (
	PoolModeDefault         MessagePoolMode = 0
	PoolModeAutoCreateQueue MessagePoolMode = 1
)

type MessageReceiveResponse

type MessageReceiveResponse struct {
	MessageResponse
	ReceiptHandle    string      `xml:"ReceiptHandle" json:"receipt_handle"`
	MessageBodyMD5   string      `xml:"MessageBodyMD5" json:"message_body_md5"`
	MessageBody      Base64Bytes `xml:"MessageBody" json:"message_body"`
	EnqueueTime      int64       `xml:"EnqueueTime" json:"enqueue_time"`
	NextVisibleTime  int64       `xml:"NextVisibleTime" json:"next_visible_time"`
	FirstDequeueTime int64       `xml:"FirstDequeueTime" json:"first_dequeue_time"`
	DequeueCount     int64       `xml:"DequeueCount" json:"dequeue_count"`
	Priority         int64       `xml:"Priority" json:"priority"`
}

type MessageResponse

type MessageResponse struct {
	XMLName   xml.Name `xml:"Message" json:"-"`
	Code      string   `xml:"Code,omitempty" json:"code,omitempty"`
	Message   string   `xml:"Message,omitempty" json:"message,omitempty"`
	RequestId string   `xml:"RequestId,omitempty" json:"request_id,omitempty"`
	HostId    string   `xml:"HostId,omitempty" json:"host_id,omitempty"`
}

type MessageSendRequest

type MessageSendRequest struct {
	XMLName      xml.Name    `xml:"Message"`
	MessageBody  Base64Bytes `xml:"MessageBody"`
	DelaySeconds int64       `xml:"DelaySeconds"`
	Priority     int64       `xml:"Priority"`
}

type MessageSendResponse

type MessageSendResponse struct {
	MessageResponse
	MessageId      string `xml:"MessageId" json:"message_id"`
	MessageBodyMD5 string `xml:"MessageBodyMD5" json:"message_body_md5"`
}

type MessageVisibilityChangeResponse

type MessageVisibilityChangeResponse struct {
	XMLName         xml.Name `xml:"ChangeVisibility" json:"-"`
	ReceiptHandle   string   `xml:"ReceiptHandle" json:"receipt_handle"`
	NextVisibleTime int64    `xml:"NextVisibleTime" json:"next_visible_time"`
}

type PoolConfig

type PoolConfig struct {
	Host            string        `json:"host"`
	OwnerId         string        `json:"owner_id"`
	AccessKeyId     string        `json:"access_key_id"`
	AccessKeySecert string        `json:"access_key_secret"`
	Mode            string        `json:"mode"`
	Queues          []QueueConfig `json:"queues"`
}

type Queue

type Queue struct {
	QueueURL string `xml:"QueueURL" json:"url"`
}

type QueueConfig

type QueueConfig struct {
	Name                   string `json:"name"`
	MaxMessageSize         int32  `json:"max_message_size"`
	MessageRetentionPeriod int64  `json:"message_retention_period"`
	VisibilityTimeout      int64  `json:"visibility_timeout"`
	PollingWaitSeconds     int64  `json:"polling_wait_seconds"`
}

type QueueProperty

type QueueProperty struct {
	Name                   string
	MaxMessageSize         int32
	MessageRetentionPeriod time.Duration
	VisibilityTimeout      time.Duration
	PollingWaitSeconds     time.Duration
}

func DefaultQueueProperty

func DefaultQueueProperty(name string) QueueProperty

type Queues

type Queues struct {
	XMLName    xml.Name    `xml:"Queues" json:"-"`
	Queues     []Queue     `xml:"Queue" json:"queues"`
	NextMarker Base64Bytes `xml:"NextMarker" json:"next_marker"`
}

type ReceiptHandles

type ReceiptHandles struct {
	XMLName        xml.Name `xml:"ReceiptHandles"`
	ReceiptHandles []string `xml:"ReceiptHandle"`
}

type TinyMQS

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

func NewTinyMQS

func NewTinyMQS() *TinyMQS

func (*TinyMQS) CreatePools

func (p *TinyMQS) CreatePools(pools []PoolConfig) (err error)

func (*TinyMQS) DeleteMessage

func (p *TinyMQS) DeleteMessage(resp http.ResponseWriter, req *http.Request, params martini.Params)

func (*TinyMQS) ReceiveMessage

func (p *TinyMQS) ReceiveMessage(resp http.ResponseWriter, req *http.Request, params martini.Params)

func (*TinyMQS) Run

func (p *TinyMQS) Run()

func (*TinyMQS) SendMessage

func (p *TinyMQS) SendMessage(resp http.ResponseWriter, req *http.Request, params martini.Params)

type TinyMQSConfig

type TinyMQSConfig struct {
	HTTP  HTTPConfig   `json:"http"`
	Pools []PoolConfig `json:"pools"`
}

func (*TinyMQSConfig) LoadConfig

func (p *TinyMQSConfig) LoadConfig(filename string) (err error)

type TinyQueueMessage

type TinyQueueMessage struct {
	Id               string
	ReceiptHandle    string
	Body             Base64Bytes
	EnqueueTime      time.Time
	DequeueCount     int64
	Priority         int64
	DelaySeconds     time.Duration
	FirstDequeueTime time.Duration
	NextDequeueTime  time.Duration
	// contains filtered or unexported fields
}

func NewTinyQueueMessage

func NewTinyQueueMessage(body Base64Bytes, delaySeconds time.Duration, priority int64, lifeCycle time.Duration) (message *TinyQueueMessage)

Jump to

Keyboard shortcuts

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