Documentation ¶
Overview ¶
Package queues provides information and interaction with the queues through the OpenStack Messaging (Zaqar) service.
Lists all queues and creates, shows information for updates, deletes, and actions on a queue.
Example to List Queues
listOpts := queues.ListOpts{ Limit: 10, } pager := queues.List(client, listOpts) err = pager.EachPage(func(page pagination.Page) (bool, error) { queues, err := queues.ExtractQueues(page) if err != nil { panic(err) } for _, queue := range queues { fmt.Printf("%+v\n", queue) } return true, nil })
Example to Create a Queue
createOpts := queues.CreateOpts{ QueueName: "My_Queue", MaxMessagesPostSize: 262143, DefaultMessageTTL: 3700, DefaultMessageDelay: 25, DeadLetterQueueMessageTTL: 3500, MaxClaimCount: 10, Extra: map[string]interface{}{"description": "Test queue."}, } err := queues.Create(client, createOpts).ExtractErr() if err != nil { panic(err) }
Example to Update a Queue
updateOpts := queues.BatchUpdateOpts{ queues.UpdateOpts{ Op: "replace", Path: "/metadata/_max_claim_count", Value: 15, }, queues.UpdateOpts{ Op: "replace", Path: "/metadata/description", Value: "Updated description test queue.", }, } updateResult, err := queues.Update(client, queueName, updateOpts).Extract() if err != nil { panic(err) }
Example to Get a Queue
queue, err := queues.Get(client, queueName).Extract() if err != nil { panic(err) }
Example to Delete a Queue
err := queues.Delete(client, queueName).ExtractErr() if err != nil { panic(err) }
Example to Get Message Stats of a Queue
queueStats, err := queues.GetStats(client, queueName).Extract() if err != nil { panic(err) }
Example to Share a queue
shareOpts := queues.ShareOpts{ Paths: []queues.SharePath{queues.ShareMessages}, Methods: []queues.ShareMethod{queues.MethodGet}, } queueShare, err := queues.Share(client, queueName, shareOpts).Extract() if err != nil { panic(err) }
Example to Purge a queue
purgeOpts := queues.PurgeOpts{ ResourceTypes: []queues.PurgeResource{ queues.ResourceMessages, }, } err := queues.Purge(client, queueName, purgeOpts).ExtractErr() if err != nil { panic(err) }
Index ¶
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type BatchUpdateOpts
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type PurgeOpts
- type PurgeOptsBuilder
- type PurgeResource
- type PurgeResult
- type Queue
- type QueueDetails
- type QueuePage
- type QueueShare
- type ShareMethod
- type ShareOpts
- type ShareOptsBuilder
- type SharePath
- type ShareResult
- type StatResult
- type Stats
- type UpdateOp
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List instructs OpenStack to provide a list of queues.
Types ¶
type BatchUpdateOpts ¶
type BatchUpdateOpts []UpdateOpts
BatchUpdateOpts is an array of UpdateOpts.
func (BatchUpdateOpts) ToQueueUpdateMap ¶
func (opts BatchUpdateOpts) ToQueueUpdateMap() ([]map[string]interface{}, error)
ToQueueUpdateMap constructs a request body from UpdateOpts.
type CreateOpts ¶
type CreateOpts struct { // The name of the queue to create. QueueName string `json:"queue_name" required:"true"` // The target incoming messages will be moved to when a message can’t // processed successfully after meet the max claim count is met. DeadLetterQueue string `json:"_dead_letter_queue,omitempty"` // The new TTL setting for messages when moved to dead letter queue. DeadLetterQueueMessagesTTL int `json:"_dead_letter_queue_messages_ttl,omitempty"` // The delay of messages defined for a queue. When the messages send to // the queue, it will be delayed for some times and means it can not be // claimed until the delay expired. DefaultMessageDelay int `json:"_default_message_delay,omitempty"` // The default TTL of messages defined for a queue, which will effect for // any messages posted to the queue. DefaultMessageTTL int `json:"_default_message_ttl" required:"true"` // The flavor name which can tell Zaqar which storage pool will be used // to create the queue. Flavor string `json:"_flavor,omitempty"` // The max number the message can be claimed. MaxClaimCount int `json:"_max_claim_count,omitempty"` // The max post size of messages defined for a queue, which will effect // for any messages posted to the queue. MaxMessagesPostSize int `json:"_max_messages_post_size,omitempty"` // Does messages should be encrypted EnableEncryptMessages *bool `json:"_enable_encrypt_messages,omitempty"` // Extra is free-form extra key/value pairs to describe the queue. Extra map[string]interface{} `json:"-"` }
CreateOpts specifies the queue creation parameters.
func (CreateOpts) ToQueueCreateMap ¶
func (opts CreateOpts) ToQueueCreateMap() (map[string]interface{}, error)
ToQueueCreateMap constructs a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
gophercloud.ErrResult
}
CreateResult is the response of a Create operation.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create requests the creation of a new queue.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the result from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, queueName string) (r DeleteResult)
Delete deletes the specified queue.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response of a Get operation.
func Get ¶
func Get(client *gophercloud.ServiceClient, queueName string) (r GetResult)
Get requests details on a single queue, by name.
func (GetResult) Extract ¶
func (r GetResult) Extract() (QueueDetails, error)
Extract interprets any commonResult as a Queue.
type ListOpts ¶
type ListOpts struct { // Limit instructs List to refrain from sending excessively large lists of queues Limit int `q:"limit,omitempty"` // Marker and Limit control paging. Marker instructs List where to start listing from. Marker string `q:"marker,omitempty"` // Specifies if showing the detailed information when querying queues Detailed bool `q:"detailed,omitempty"` // Specifies if filter the queues by queue’s name when querying queues. Name bool `q:"name,omitempty"` // Specifies if showing the amount of queues when querying them. WithCount bool `q:"with_count,omitempty"` }
ListOpts params to be used with List
func (ListOpts) ToQueueListQuery ¶
ToQueueListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type PurgeOpts ¶
type PurgeOpts struct {
ResourceTypes []PurgeResource `json:"resource_types" required:"true"`
}
PurgeOpts specifies the purge parameters.
func (PurgeOpts) ToQueuePurgeMap ¶
ToPurgeQueueMap formats a PurgeOpts structure into a request body
type PurgeOptsBuilder ¶
PurgeOptsBuilder allows extensions to add additional attributes to the Purge request.
type PurgeResource ¶
type PurgeResource string
const ( ResourceMessages PurgeResource = "messages" ResourceSubscriptions PurgeResource = "subscriptions" )
type PurgeResult ¶
type PurgeResult struct {
gophercloud.ErrResult
}
PurgeResult is the response of a Purge operation.
func Purge ¶
func Purge(client *gophercloud.ServiceClient, queueName string, opts PurgeOptsBuilder) (r PurgeResult)
Purge purges particular resource of the queue.
type Queue ¶
type Queue struct { Href string `json:"href"` Methods []string `json:"methods"` Name string `json:"name"` Paths []string `json:"paths"` ResourceTypes []string `json:"resource_types"` Metadata QueueDetails `json:"metadata"` }
Queue represents a messaging queue.
func ExtractQueues ¶
func ExtractQueues(r pagination.Page) ([]Queue, error)
ExtractQueues interprets the results of a single page from a List() call, producing a map of queues.
type QueueDetails ¶
type QueueDetails struct { // The queue the message will be moved to when the message can’t // be processed successfully after the max claim count is met. DeadLetterQueue string `json:"_dead_letter_queue"` // The TTL setting for messages when moved to dead letter queue. DeadLetterQueueMessageTTL int `json:"_dead_letter_queue_messages_ttl"` // The delay of messages defined for the queue. DefaultMessageDelay int `json:"_default_message_delay"` // The default TTL of messages defined for the queue. DefaultMessageTTL int `json:"_default_message_ttl"` // Extra is a collection of miscellaneous key/values. Extra map[string]interface{} `json:"-"` // The max number the message can be claimed from the queue. MaxClaimCount int `json:"_max_claim_count"` // The max post size of messages defined for the queue. MaxMessagesPostSize int `json:"_max_messages_post_size"` // Is message encryption enabled EnableEncryptMessages bool `json:"_enable_encrypt_messages"` // The flavor defined for the queue. Flavor string `json:"flavor"` }
QueueDetails represents the metadata of a queue.
func (*QueueDetails) UnmarshalJSON ¶
func (r *QueueDetails) UnmarshalJSON(b []byte) error
type QueuePage ¶
type QueuePage struct {
pagination.LinkedPageBase
}
QueuePage contains a single page of all queues from a List operation.
func (QueuePage) NextPageURL ¶
NextPageURL uses the response's embedded link reference to navigate to the next page of results.
type ShareMethod ¶
type ShareMethod string
const ( MethodGet ShareMethod = "GET" MethodPatch ShareMethod = "PATCH" MethodPost ShareMethod = "POST" MethodPut ShareMethod = "PUT" )
type ShareOpts ¶
type ShareOpts struct {}
ShareOpts specifies share creation parameters.
func (ShareOpts) ToQueueShareMap ¶
ToShareQueueMap formats a ShareOpts structure into a request body.
type ShareOptsBuilder ¶
type ShareOptsBuilder interface {
}ShareOptsBuilder allows extensions to add additional attributes to the Share request.
type ShareResult ¶
type ShareResult struct {
}ShareResult contains the result of a Share operation.
func Share ¶
func Share(client *gophercloud.ServiceClient, queueName string, opts ShareOptsBuilder) (r ShareResult)
Share creates a pre-signed URL for a given queue.
func (ShareResult) Extract ¶
func (r ShareResult) Extract() (QueueShare, error)
Extract interprets any ShareResult as a QueueShare.
type StatResult ¶
type StatResult struct {
gophercloud.Result
}
StatResult contains the result of a Share operation.
func GetStats ¶
func GetStats(client *gophercloud.ServiceClient, queueName string) (r StatResult)
GetStats returns statistics for the specified queue.
func (StatResult) Extract ¶
func (r StatResult) Extract() (Stats, error)
Extract interprets any StatResult as a Stats.
type Stats ¶
type Stats struct { // Number of Claimed messages for a queue Claimed int `json:"claimed"` // Total Messages for a queue Total int `json:"total"` // Number of free messages Free int `json:"free"` }
Stats represents a stats response.
type UpdateOpts ¶
type UpdateOpts struct { Op UpdateOp `json:"op" required:"true"` Path string `json:"path" required:"true"` Value interface{} `json:"value" required:"true"` }
UpdateOpts is the struct responsible for updating a property of a queue.
func (UpdateOpts) ToMap ¶
func (opts UpdateOpts) ToMap() (map[string]interface{}, error)
ToMap constructs a request body from UpdateOpts.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult is the response of a Update operation.
func Update ¶
func Update(client *gophercloud.ServiceClient, queueName string, opts UpdateOptsBuilder) (r UpdateResult)
Update Updates the specified queue.
func (UpdateResult) Extract ¶
func (r UpdateResult) Extract() (QueueDetails, error)
Extract interprets any commonResult as a Queue.