messages

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

Queue Storage Messages SDK for API version 2023-11-03

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"

	"github.com/hashicorp/go-azure-sdk/sdk/auth"
	"github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/messages"
)

func Example() error {
	accountName := "storageaccount1"
    storageAccountKey := "ABC123...."
    queueName := "myqueue"
	domainSuffix := "core.windows.net"

	auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey)
	if err != nil {
		return fmt.Errorf("building SharedKey authorizer: %+v", err)
	}
    
    messagesClient, err  := messages.NewWithBaseUri(fmt.Sprintf("https://%s.queue.%s", accountName, domainSuffix))
	if err != nil {
		return fmt.Errorf("building client for environment: %+v", err)
	}
    messagesClient.Client.SetAuthorizer(auth)
    
    ctx := context.TODO()
    input := messages.PutInput{
    	Message: "<over><message>hello</message></over>",
    }
    if _, err := messagesClient.Put(ctx, queueName, input); err != nil {
        return fmt.Errorf("Error creating Message: %s", err)
    }
    
    return nil 
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client *storage.Client
}

Client is the base client for Messages.

func NewWithBaseUri

func NewWithBaseUri(baseUri string) (*Client, error)

func (Client) Delete

func (c Client) Delete(ctx context.Context, queueName, messageID string, input DeleteInput) (result DeleteResponse, err error)

Delete deletes a specific message

func (Client) Get

func (c Client) Get(ctx context.Context, queueName string, input GetInput) (result QueueMessagesListResponse, err error)

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

func (Client) Peek

func (c Client) Peek(ctx context.Context, queueName string, input PeekInput) (result QueueMessagesListResponse, 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) Put

func (c Client) Put(ctx context.Context, queueName string, input PutInput) (result QueueMessagesListResponse, err error)

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

func (Client) Update

func (c Client) Update(ctx context.Context, queueName string, messageID string, input UpdateInput) (result UpdateResponse, err error)

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

type DeleteInput

type DeleteInput struct {
	PopReceipt string
}

type DeleteResponse

type DeleteResponse struct {
	HttpResponse *http.Response
}

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

	// NumberOfMessages specifies the (maximum) number of messages that should be retrieved from the queue.
	// This can be a maximum of 32.
	NumberOfMessages int
}

type PeekInput

type PeekInput struct {
	// NumberOfMessages specifies the (maximum) number of messages that should be peak'd from the front of the queue.
	// This can be a maximum of 32.
	NumberOfMessages 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 QueueMessagesListResponse

type QueueMessagesListResponse struct {
	HttpResponse *http.Response

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

type StorageQueueMessage

type StorageQueueMessage interface {
	Delete(ctx context.Context, queueName string, messageID string, input DeleteInput) (DeleteResponse, error)
	Peek(ctx context.Context, queueName string, input PeekInput) (QueueMessagesListResponse, error)
	Put(ctx context.Context, queueName string, input PutInput) (QueueMessagesListResponse, error)
	Get(ctx context.Context, queueName string, input GetInput) (QueueMessagesListResponse, error)
	Update(ctx context.Context, queueName string, messageID string, input UpdateInput) (UpdateResponse, 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
}

type UpdateResponse

type UpdateResponse struct {
	HttpResponse *http.Response
}

Jump to

Keyboard shortcuts

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