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(cclient, listOpts) err = pager.EachPage(context.TODO(), func(_ context.Context, 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]any{"description": "Test queue."}, } err := queues.Create(context.TODO(), 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(context.TODO(), client, queueName, updateOpts).Extract() if err != nil { panic(err) }
Example to Get a Queue
queue, err := queues.Get(context.TODO(), client, queueName).Extract() if err != nil { panic(err) }
Example to Delete a Queue
err := queues.Delete(context.TODO(), client, queueName).ExtractErr() if err != nil { panic(err) }
Example to Get Message Stats of a Queue
queueStats, err := queues.GetStats(context.TODO(), 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(context.TODO(), 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(context.TODO(), 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]any, 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]any `json:"-"` }
CreateOpts specifies the queue creation parameters.
func (CreateOpts) ToQueueCreateMap ¶
func (opts CreateOpts) ToQueueCreateMap() (map[string]any, 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(ctx context.Context, 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.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response of a Get operation.
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.
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(ctx context.Context, 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]any `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 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(ctx context.Context, 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(ctx context.Context, 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 any `json:"value" required:"true"` }
UpdateOpts is the struct responsible for updating a property of a queue.
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(ctx context.Context, 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.