messages

package
v1.1.35 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package messages provides information and interaction with the messages through the OpenStack Messaging(Zaqar) service.

Example to List Messages

listOpts := messages.ListOpts{
	Limit: 10,
}

queueName := "my_queue"

pager := messages.List(client, queueName, listOpts)

err = pager.EachPage(func(page pagination.Page) (bool, error) {
	allMessages, err := queues.ExtractQueues(page)
	if err != nil {
		panic(err)
	}

	for _, message := range allMessages {
		fmt.Printf("%+v\n", message)
	}

	return true, nil
})

Example to Create Messages

queueName = "my_queue"

createOpts := messages.CreateOpts{
	Messages:     []messages.Messages{
		{
			TTL:   300,
			Delay: 20,
			Body: map[string]interface{}{
				"event": "BackupStarted",
				"backup_id": "c378813c-3f0b-11e2-ad92-7823d2b0f3ce",
			},
		},
		{
			Body: map[string]interface{}{
				"event": "BackupProgress",
				"current_bytes": "0",
				"total_bytes": "99614720",
			},
		},
	},
}

resources, err := messages.Create(client, queueName, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Get a set of Messages

queueName := "my_queue"

getMessageOpts := messages.GetMessagesOpts{
	IDs: "123456",
}

messagesList, err := messages.GetMessages(client, createdQueueName, getMessageOpts).Extract()
if err != nil {
	panic(err)
}

Example to get a singular Message

queueName := "my_queue"
messageID := "123456"

message, err := messages.Get(client, queueName, messageID).Extract()
if err != nil {
	panic(err)
}

Example to Delete a set of Messages

queueName := "my_queue"

deleteMessagesOpts := messages.DeleteMessagesOpts{
	IDs: []string{"9988776655"},
}

err := messages.DeleteMessages(client, queueName, deleteMessagesOpts).ExtractErr()
if err != nil {
	panic(err)
}

Example to Pop a set of Messages

queueName := "my_queue"

popMessagesOpts := messages.PopMessagesOpts{
	Pop: 5,
}

resources, err := messages.PopMessages(client, queueName, popMessagesOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a singular Message

clientID := "3381af92-2b9e-11e3-b191-71861300734d"
queueName := "my_queue"
messageID := "123456"

deleteOpts := messages.DeleteOpts{
	ClaimID: "12345",
}

err := messages.Delete(client), queueName, messageID, deleteOpts).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteMessageURL

func DeleteMessageURL(client *gophercloud.ServiceClient, queueName string, messageID string) string

func List

func List(client *gophercloud.ServiceClient, queueName string, opts ListOptsBuilder) pagination.Pager

ListMessages lists messages on a specific queue based off queue name.

Types

type BatchCreateOpts

type BatchCreateOpts []CreateOpts

BatchCreateOpts is an array of CreateOpts.

func (BatchCreateOpts) ToMessageCreateMap

func (opts BatchCreateOpts) ToMessageCreateMap() (map[string]interface{}, error)

ToMessageCreateMap constructs a request body from BatchCreateOpts.

type CreateOpts

type CreateOpts struct {
	// TTL specifies how long the server waits before marking the message
	// as expired and removing it from the queue.
	TTL int `json:"ttl,omitempty"`

	// Delay specifies how long the message can be claimed.
	Delay int `json:"delay,omitempty"`

	// Body specifies an arbitrary document that constitutes the body of the message being sent.
	Body map[string]interface{} `json:"body" required:"true"`
}

CreateOpts params to be used with Create.

func (CreateOpts) ToMap

func (opts CreateOpts) ToMap() (map[string]interface{}, error)

ToMap constructs a request body from UpdateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToMessageCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder Builder.

type CreateResult

type CreateResult struct {
	gophercloud.Result
}

CreateResult is the response of a Create operations.

func Create

func Create(client *gophercloud.ServiceClient, queueName string, opts CreateOptsBuilder) (r CreateResult)

Create creates a message on a specific queue based of off queue name.

func (CreateResult) Extract

func (r CreateResult) Extract() (ResourceList, error)

Extract interprets any CreateResult as a ResourceList.

type DeleteMessagesOpts

type DeleteMessagesOpts struct {
	IDs []string `q:"ids,omitempty"`
}

DeleteMessagesOpts params to be used with DeleteMessages.

func (DeleteMessagesOpts) ToMessagesDeleteQuery

func (opts DeleteMessagesOpts) ToMessagesDeleteQuery() (string, error)

ToMessagesDeleteQuery formats a DeleteMessagesOpts structure into a query string.

type DeleteMessagesOptsBuilder

type DeleteMessagesOptsBuilder interface {
	ToMessagesDeleteQuery() (string, error)
}

DeleteMessagesOptsBuilder allows extensions to add additional parameters to the DeleteMessages request.

type DeleteOpts

type DeleteOpts struct {
	// ClaimID instructs Delete to delete a message that is associated with a claim ID
	ClaimID string `q:"claim_id,omitempty"`
}

DeleteOpts params to be used with Delete.

func (DeleteOpts) ToMessageDeleteQuery

func (opts DeleteOpts) ToMessageDeleteQuery() (string, error)

ToMessageDeleteQuery formats a DeleteOpts structure into a query string.

type DeleteOptsBuilder

type DeleteOptsBuilder interface {
	ToMessageDeleteQuery() (string, error)
}

DeleteOptsBuilder allows extensions to add additional parameters to the delete request.

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, messageID string, opts DeleteOptsBuilder) (r DeleteResult)

Delete deletes a specific message from the queue.

func DeleteMessages

func DeleteMessages(client *gophercloud.ServiceClient, queueName string, opts DeleteMessagesOptsBuilder) (r DeleteResult)

DeleteMessages deletes multiple messages based off of ID.

type GetMessagesOpts

type GetMessagesOpts struct {
	IDs []string `q:"ids,omitempty"`
}

GetMessagesOpts params to be used with GetMessages.

func (GetMessagesOpts) ToGetMessagesListQuery

func (opts GetMessagesOpts) ToGetMessagesListQuery() (string, error)

ToGetMessagesListQuery formats a GetMessagesOpts structure into a query string.

type GetMessagesOptsBuilder

type GetMessagesOptsBuilder interface {
	ToGetMessagesListQuery() (string, error)
}

GetMessagesOptsBuilder allows extensions to add additional parameters to the GetMessages request.

type GetMessagesResult

type GetMessagesResult struct {
	gophercloud.Result
}

GetMessagesResult is the response of a GetMessages operations.

func GetMessages

func GetMessages(client *gophercloud.ServiceClient, queueName string, opts GetMessagesOptsBuilder) (r GetMessagesResult)

GetMessages requests details on a multiple messages, by IDs.

func (GetMessagesResult) Extract

func (r GetMessagesResult) Extract() ([]Message, error)

Extract interprets any GetMessagesResult as a list of Message.

type GetResult

type GetResult struct {
	gophercloud.Result
}

GetResult is the response of a Get operations.

func Get

func Get(client *gophercloud.ServiceClient, queueName string, messageID string) (r GetResult)

Get requests details on a single message, by ID.

func (GetResult) Extract

func (r GetResult) Extract() (Message, error)

Extract interprets any GetResult as a Message.

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"`

	// Indicate if the messages can be echoed back to the client that posted them.
	Echo bool `q:"echo,omitempty"`

	// Indicate if the messages list should include the claimed messages.
	IncludeClaimed bool `q:"include_claimed,omitempty"`

	//Indicate if the messages list should include the delayed messages.
	IncludeDelayed bool `q:"include_delayed,omitempty"`
}

ListOpts params to be used with List.

func (ListOpts) ToMessageListQuery

func (opts ListOpts) ToMessageListQuery() (string, error)

type ListOptsBuilder

type ListOptsBuilder interface {
	ToMessageListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Message

type Message struct {
	Body     map[string]interface{} `json:"body"`
	Age      int                    `json:"age"`
	Href     string                 `json:"href"`
	ID       string                 `json:"id"`
	TTL      int                    `json:"ttl"`
	Checksum string                 `json:"checksum"`
}

Message represents a message on a queue.

func ExtractMessages

func ExtractMessages(r pagination.Page) ([]Message, error)

ExtractMessage extracts message into a list of Message.

type MessagePage

type MessagePage struct {
	pagination.LinkedPageBase
}

MessagePage contains a single page of all clusters from a ListDetails call.

func (MessagePage) IsEmpty

func (r MessagePage) IsEmpty() (bool, error)

IsEmpty determines if a MessagePage contains any results.

func (MessagePage) NextPageURL

func (r MessagePage) NextPageURL() (string, error)

NextPageURL uses the response's embedded link reference to navigate to the next page of results.

type PopMessage

type PopMessage struct {
	Body       map[string]interface{} `json:"body"`
	Age        int                    `json:"age"`
	ID         string                 `json:"id"`
	TTL        int                    `json:"ttl"`
	ClaimCount int                    `json:"claim_count"`
	ClaimID    string                 `json:"claim_id"`
}

PopMessage represents a message returned from PopMessages.

type PopMessagesOpts

type PopMessagesOpts struct {
	Pop int `q:"pop,omitempty"`
}

PopMessagesOpts params to be used with PopMessages.

func (PopMessagesOpts) ToMessagesPopQuery

func (opts PopMessagesOpts) ToMessagesPopQuery() (string, error)

ToMessagesPopQuery formats a PopMessagesOpts structure into a query string.

type PopMessagesOptsBuilder

type PopMessagesOptsBuilder interface {
	ToMessagesPopQuery() (string, error)
}

PopMessagesOptsBuilder allows extensions to add additional parameters to the DeleteMessages request.

type PopResult

type PopResult struct {
	gophercloud.Result
}

CreateResult is the response of a Create operations.

func PopMessages

func PopMessages(client *gophercloud.ServiceClient, queueName string, opts PopMessagesOptsBuilder) (r PopResult)

PopMessages deletes and returns multiple messages based off of number of messages.

func (PopResult) Extract

func (r PopResult) Extract() ([]PopMessage, error)

Extract interprets any PopResult as a list of PopMessage.

type ResourceList

type ResourceList struct {
	Resources []string `json:"resources"`
}

ResourceList represents the result of creating a message.

Directories

Path Synopsis
messages unit tests
messages unit tests

Jump to

Keyboard shortcuts

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