messages

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

Queue Storage Messages SDK for API version 2018-11-09

This package allows you to interact with the Messages Queue Storage API

Supported Authorizers

  • Azure Active Directory (for the Resource Endpoint https://storage.azure.com)
  • SharedKeyLite (Blob, File & Queue)

Example Usage

package main

import (
	"context"
	"fmt"
	"time"
	
	"github.com/Azure/go-autorest/autorest"
	"github.com/tombuildsstuff/giovanni/storage/2018-11-09/queue/messages"
)

func Example() error {
	accountName := "storageaccount1"
    storageAccountKey := "ABC123...."
    queueName := "myqueue"
    
    storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey)
    messagesClient := messages.New()
    messagesClient.Client.Authorizer = storageAuth
    
    ctx := context.TODO()
    input := messages.PutInput{
    	Message: "<over><message>hello</message></over>",
    }
    if _, err := messagesClient.Put(ctx, accountName, queueName, input); err != nil {
        return fmt.Errorf("Error creating Message: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

View Source
const APIVersion = "2018-11-09"

APIVersion is the version of the API used for all Storage API Operations

Variables

This section is empty.

Functions

func UserAgent

func UserAgent() string

Types

type Client

type Client struct {
	autorest.Client
	BaseURI string
}

Client is the base client for Messages.

func New

func New() Client

New creates an instance of the Client client.

func NewWithEnvironment

func NewWithEnvironment(environment azure.Environment) Client

NewWithEnvironment creates an instance of the Client client.

func (Client) Delete

func (client Client) Delete(ctx context.Context, accountName, queueName, messageID, popReceipt string) (result autorest.Response, err error)

Delete deletes a specific message

func (Client) DeletePreparer

func (client Client) DeletePreparer(ctx context.Context, accountName, queueName, messageID, popReceipt string) (*http.Request, error)

DeletePreparer prepares the Delete request.

func (Client) DeleteResponder

func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error)

DeleteResponder handles the response to the Delete request. The method always closes the http.Response Body.

func (Client) DeleteSender

func (client Client) DeleteSender(req *http.Request) (*http.Response, error)

DeleteSender sends the Delete request. The method will close the http.Response Body if it receives an error.

func (Client) Get

func (client Client) Get(ctx context.Context, accountName, queueName string, numberOfMessages int, input GetInput) (result QueueMessagesListResult, err error)

Get retrieves one or more messages from the front of the queue

func (Client) GetPreparer

func (client Client) GetPreparer(ctx context.Context, accountName, queueName string, numberOfMessages int, input GetInput) (*http.Request, error)

GetPreparer prepares the Get request.

func (Client) GetResourceID

func (client Client) GetResourceID(accountName, queueName, messageID string) string

GetResourceID returns the Resource ID for the given Message within a Queue This can be useful when, for example, you're using this as a unique identifier

func (Client) GetResponder

func (client Client) GetResponder(resp *http.Response) (result QueueMessagesListResult, err error)

GetResponder handles the response to the Get request. The method always closes the http.Response Body.

func (Client) GetSender

func (client Client) GetSender(req *http.Request) (*http.Response, error)

GetSender sends the Get request. The method will close the http.Response Body if it receives an error.

func (Client) Peek

func (client Client) Peek(ctx context.Context, accountName, queueName string, numberOfMessages int) (result QueueMessagesListResult, err error)

Peek retrieves one or more messages from the front of the queue, but doesn't alter the visibility of the messages

func (Client) PeekPreparer

func (client Client) PeekPreparer(ctx context.Context, accountName, queueName string, numberOfMessages int) (*http.Request, error)

PeekPreparer prepares the Peek request.

func (Client) PeekResponder

func (client Client) PeekResponder(resp *http.Response) (result QueueMessagesListResult, err error)

PeekResponder handles the response to the Peek request. The method always closes the http.Response Body.

func (Client) PeekSender

func (client Client) PeekSender(req *http.Request) (*http.Response, error)

PeekSender sends the Peek request. The method will close the http.Response Body if it receives an error.

func (Client) Put

func (client Client) Put(ctx context.Context, accountName, queueName string, input PutInput) (result QueueMessagesListResult, err error)

Put adds a new message to the back of the message queue

func (Client) PutPreparer

func (client Client) PutPreparer(ctx context.Context, accountName, queueName string, input PutInput) (*http.Request, error)

PutPreparer prepares the Put request.

func (Client) PutResponder

func (client Client) PutResponder(resp *http.Response) (result QueueMessagesListResult, err error)

PutResponder handles the response to the Put request. The method always closes the http.Response Body.

func (Client) PutSender

func (client Client) PutSender(req *http.Request) (*http.Response, error)

PutSender sends the Put request. The method will close the http.Response Body if it receives an error.

func (Client) Update

func (client Client) Update(ctx context.Context, accountName, queueName string, messageID string, input UpdateInput) (result autorest.Response, err error)

Update updates an existing message based on it's Pop Receipt

func (Client) UpdatePreparer

func (client Client) UpdatePreparer(ctx context.Context, accountName, queueName string, messageID string, input UpdateInput) (*http.Request, error)

UpdatePreparer prepares the Update request.

func (Client) UpdateResponder

func (client Client) UpdateResponder(resp *http.Response) (result autorest.Response, err error)

UpdateResponder handles the response to the Update request. The method always closes the http.Response Body.

func (Client) UpdateSender

func (client Client) UpdateSender(req *http.Request) (*http.Response, error)

UpdateSender sends the Update request. The method will close the http.Response Body if it receives an error.

type GetInput

type GetInput struct {
	// VisibilityTimeout specifies the new visibility timeout value, in seconds, relative to server time.
	// The new value must be larger than or equal to 0, and cannot be larger than 7 days.
	VisibilityTimeout *int
}

type PutInput

type PutInput struct {
	// A message must be in a format that can be included in an XML request with UTF-8 encoding.
	// The encoded message can be up to 64 KB in size.
	Message string

	// The maximum time-to-live can be any positive number,
	// as well as -1 indicating that the message does not expire.
	// If this parameter is omitted, the default time-to-live is 7 days.
	MessageTtl *int

	// Specifies the new visibility timeout value, in seconds, relative to server time.
	// The new value must be larger than or equal to 0, and cannot be larger than 7 days.
	// The visibility timeout of a message cannot be set to a value later than the expiry time.
	// visibilitytimeout should be set to a value smaller than the time-to-live value.
	// If not specified, the default value is 0.
	VisibilityTimeout *int
}

type QueueMessage

type QueueMessage struct {
	MessageText string `xml:"MessageText"`
}

type QueueMessageResponse

type QueueMessageResponse struct {
	MessageId       string `xml:"MessageId"`
	InsertionTime   string `xml:"InsertionTime"`
	ExpirationTime  string `xml:"ExpirationTime"`
	PopReceipt      string `xml:"PopReceipt"`
	TimeNextVisible string `xml:"TimeNextVisible"`
}

type QueueMessagesListResult

type QueueMessagesListResult struct {
	autorest.Response

	QueueMessages *[]QueueMessageResponse `xml:"QueueMessage"`
}

type ResourceID

type ResourceID struct {
	AccountName string
	QueueName   string
	MessageID   string
}

func ParseResourceID added in v0.2.0

func ParseResourceID(id string) (*ResourceID, error)

ParseResourceID parses the specified Resource ID and returns an object which can be used to interact with the Message within a Queue

type StorageQueueMessage added in v0.11.0

type StorageQueueMessage interface {
	Delete(ctx context.Context, accountName, queueName, messageID, popReceipt string) (result autorest.Response, err error)
	Peek(ctx context.Context, accountName, queueName string, numberOfMessages int) (result QueueMessagesListResult, err error)
	GetResourceID(accountName, queueName, messageID string) string
	Put(ctx context.Context, accountName, queueName string, input PutInput) (result QueueMessagesListResult, err error)
	Get(ctx context.Context, accountName, queueName string, numberOfMessages int, input GetInput) (result QueueMessagesListResult, err error)
	Update(ctx context.Context, accountName, queueName string, messageID string, input UpdateInput) (result autorest.Response, err error)
}

type UpdateInput

type UpdateInput struct {
	// A message must be in a format that can be included in an XML request with UTF-8 encoding.
	// The encoded message can be up to 64 KB in size.
	Message string

	// Specifies the valid pop receipt value required to modify this message.
	PopReceipt string

	// Specifies the new visibility timeout value, in seconds, relative to server time.
	// The new value must be larger than or equal to 0, and cannot be larger than 7 days.
	// The visibility timeout of a message cannot be set to a value later than the expiry time.
	// A message can be updated until it has been deleted or has expired.
	VisibilityTimeout int
}

Jump to

Keyboard shortcuts

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