azqueue

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 15 Imported by: 11

README

Azure Queue Storage SDK for Go

Service Version: 2018-03-28

Azure Queue storage is a service for storing large numbers of messages that can be accessed from anywhere in the world via authenticated calls using HTTP or HTTPS. A single queue message can be up to 64 KiB in size, and a queue can contain millions of messages, up to the total capacity limit of a storage account.

Source code | API reference documentation | REST API documentation

Getting started

Install the package

Install the Azure Queue Storage SDK for Go with go get:

go get github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue

If you're going to authenticate with Azure Active Directory (recommended), install the azidentity module.

go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
Prerequisites

A supported Go version (the Azure SDK supports the two most recent Go releases).

You need an Azure subscription and a Storage Account to use this package.

To create a new Storage Account, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:

az storage account create --name MyStorageAccount --resource-group MyResourceGroup --location westus --sku Standard_LRS
Authenticate the client

In order to interact with the Azure Queue Storage service, you'll need to create an instance of the azqueue.ServiceClient type. The azidentity module makes it easy to add Azure Active Directory support for authenticating Azure SDK clients with their corresponding Azure services.

// create a credential for authenticating with Azure Active Directory
cred, err := azidentity.NewDefaultAzureCredential(nil)
// TODO: handle err

// create an azqueue.ServiceClient for the specified storage account that uses the above credential
client, err := azqueue.NewServiceClient("https://MYSTORAGEACCOUNT.queue.core.windows.net/", cred, nil)
// TODO: handle err

Learn more about enabling Azure Active Directory for authentication with Azure Storage in our documentation and our samples.

Key concepts

The following components make up the Azure Queue Service:

  • The storage account itself
  • A queue within the storage account, which contains a set of messages
  • A message within a queue, in any format, of up to 64 KiB

The Azure Storage Queues client library for GO allows you to interact with each of these components through the use of a dedicated client object.

Clients

Two different clients are provided to interact with the various components of the Queue Service:

  1. ServiceClient - this client represents interaction with the Azure storage account itself, and allows you to acquire preconfigured client instances to access the queues within. It provides operations to retrieve and configure the account properties as well as list, create, and delete queues within the account. To perform operations on a specific queue, retrieve a client using the NewQueueClient method.
  2. QueueClient - this client represents interaction with a specific queue (which need not exist yet). It provides operations to create, delete, or configure a queue and includes operations to enqueue, dequeue, peek, delete, and update messages within it.
Messages
  • Enqueue - Adds a message to the queue and optionally sets a visibility timeout for the message.
  • Dequeue - Retrieves a message from the queue and makes it invisible to other consumers.
  • Peek - Retrieves a message from the front of the queue, without changing the message visibility.
  • Update - Updates the visibility timeout of a message and/or the message contents.
  • Delete - Deletes a specified message from the queue.
  • Clear - Clears all messages from the queue.
Goroutine safety

We guarantee that all client instance methods are goroutine-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across goroutines.

About Queue metadata

Queue metadata name/value pairs are valid HTTP headers and should adhere to all restrictions governing HTTP headers. Metadata names must be valid HTTP header names, may contain only ASCII characters, and should be treated as case-insensitive. Base64-encode or URL-encode metadata values containing non-ASCII characters.

Additional concepts

Client options | Accessing the response | Handling failures | Logging

Examples

Queue Manipulation
const (
	accountName   = "MYSTORAGEACCOUNT"
	accountKey    = "ACCOUNT_KEY"
	queueName     = "samplequeue"
)
Exploring Queue Service APIs
// shared key credential set up
cred := azqueue.NewSharedKeyCredential(accountName, accountKey)

// instantiate service client
serviceClient, err := azqueue.NewServiceClientWithSharedKeyCredential(account, cred, nil)
// TODO: handle error

// 1. create queue
queueClient := serviceClient.NewQueueClient(queueName)
_, err = queueClient.Create(context.TODO(), nil)
// TODO: handle error

// 2. enqueue message
_, err = queueClient.EnqueueMessage(context.TODO(), message, nil)
// TODO: handle error

// 3. dequeue message
_, err = queueClient.DequeueMessage(context.TODO(), nil)
// TODO: handle error

// 4. delete queue
_, err =queueClient.Delete(context.TODO(), nil)
// TODO: handle error
Enumerating queues
const (
	account = "https://MYSTORAGEACCOUNT.queue.core.windows.net/"
)

// authenticate with Azure Active Directory
cred, err := azidentity.NewDefaultAzureCredential(nil)
// TODO: handle error

// create a client for the specified storage account
client, err := azqueue.NewServiceClient(account, cred, nil)
// TODO: handle error

// queue listings are returned across multiple pages
pager := client.NewListQueuesPager(nil)

// continue fetching pages until no more remain
for pager.More() {
   resp, err := pager.NextPage(context.Background())
   _require.Nil(err)
   // print queue name
   for _, queue := range resp.Queues {
		fmt.Println(*queue.Name)
	}
}

Troubleshooting

All queue service operations will return an *azcore.ResponseError on failure with a populated ErrorCode field. Many of these errors are recoverable. The queueerror package provides the possible Storage error codes along with various helper facilities for error handling.

const (
	connectionString = "<connection_string>"
	queueName        = "samplequeue"
)

// create a client with the provided connection string
client, err := azqueue.NewServiceClientFromConnectionString(connectionString, nil)
// TODO: handle error

// try to delete the queue, avoiding any potential race conditions with an in-progress or completed deletion
_, err = client.DeleteQueue(context.TODO(), queueName, nil)

if queueerror.HasCode(err, queueerror.QueueBeingDeleted, queueerror.QueueNotFound) {
	// ignore any errors if the queue is being deleted or already has been deleted
} else if err != nil {
	// TODO: some other error
}

Next steps

Get started with our Queue samples. They contain complete examples of the above snippets and more.

Contributing

See the Storage CONTRIBUTING.md for details on building, testing, and contributing to this library.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution.

If you'd like to contribute to this library, please read the [contributing guide] contributing_guide to learn more about how to build and test the code.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Overview

Example (Client_Clear_Messages)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	resp, err := client.CreateQueue(context.TODO(), "testqueue", &azqueue.CreateOptions{
		Metadata: map[string]*string{"hello": to.Ptr("world")},
	})
	handleError(err)
	fmt.Println(resp)

	queueClient := client.NewQueueClient("testqueue")
	resp1, err := queueClient.EnqueueMessage(context.Background(), "test content", nil)
	handleError(err)
	fmt.Println(resp1)

	resp2, err := queueClient.ClearMessages(context.Background(), nil)
	handleError(err)
	fmt.Println(resp2)

	// delete the queue
	_, err = client.DeleteQueue(context.TODO(), "testqueue", nil)
	handleError(err)
	fmt.Println(resp)
}
Output:

Example (Client_CreateQueue)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	resp, err := client.CreateQueue(context.TODO(), "testqueue", &azqueue.CreateOptions{
		Metadata: map[string]*string{"hello": to.Ptr("world")},
	})
	handleError(err)
	fmt.Println(resp)

	// delete the queue
	_, err = client.DeleteQueue(context.TODO(), "testqueue", nil)
	handleError(err)
	fmt.Println(resp)
}
Output:

Example (Client_DeleteQueue)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	opts := &azqueue.DeleteOptions{} // or just pass nil to the method below
	resp, err := client.DeleteQueue(context.TODO(), "testqueue", opts)
	handleError(err)
	fmt.Println(resp)
}
Output:

Example (Client_Enqueue_DequeueMessage)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	resp, err := client.CreateQueue(context.TODO(), "testqueue", &azqueue.CreateOptions{
		Metadata: map[string]*string{"hello": to.Ptr("world")},
	})
	handleError(err)
	fmt.Println(resp)

	opts := &azqueue.EnqueueMessageOptions{TimeToLive: to.Ptr(int32(10))}
	queueClient := client.NewQueueClient("testqueue")
	resp1, err := queueClient.EnqueueMessage(context.Background(), "test content", opts)
	handleError(err)
	fmt.Println(resp1)

	resp2, err := queueClient.DequeueMessage(context.Background(), nil)
	handleError(err)
	// check message content
	fmt.Println(resp2.Messages[0].MessageText)

	// delete the queue
	_, err = client.DeleteQueue(context.TODO(), "testqueue", nil)
	handleError(err)
	fmt.Println(resp)
}
Output:

Example (Client_NewClient)
package main

import (
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	// this example uses Azure Active Directory (AAD) to authenticate with Azure Queue Storage
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	// https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#DefaultAzureCredential
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	fmt.Println(client.URL())
}
Output:

Example (Client_NewClientFromConnectionString)
package main

import (
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	// this example uses a connection string to authenticate with Azure queue Storage
	connectionString, ok := os.LookupEnv("AZURE_STORAGE_CONNECTION_STRING")
	if !ok {
		log.Fatal("the environment variable 'AZURE_STORAGE_CONNECTION_STRING' could not be found")
	}

	serviceClient, err := azqueue.NewServiceClientFromConnectionString(connectionString, nil)
	handleError(err)
	fmt.Println(serviceClient.URL())
}
Output:

Example (Client_NewClientWithSharedKeyCredential)
package main

import (
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	// this example uses a shared key to authenticate with Azure queue Storage
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	accountKey, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_KEY")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_KEY could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	// shared key authentication requires the storage account name and access key
	cred, err := azqueue.NewSharedKeyCredential(accountName, accountKey)
	handleError(err)
	serviceClient, err := azqueue.NewServiceClientWithSharedKeyCredential(serviceURL, cred, nil)
	handleError(err)
	fmt.Println(serviceClient.URL())
}
Output:

Example (Client_NewListQueuesPager)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	pager := client.NewListQueuesPager(&azqueue.ListQueuesOptions{
		Include: azqueue.ListQueuesInclude{Metadata: true},
	})

	// list pre-existing queues
	for pager.More() {
		resp, err := pager.NextPage(context.Background())
		handleError(err) // if err is not nil, break the loop.
		for _, _queue := range resp.Queues {
			fmt.Printf("%v", _queue)
		}
	}
}
Output:

Example (Client_PeekMessages)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	resp, err := client.CreateQueue(context.TODO(), "testqueue", &azqueue.CreateOptions{
		Metadata: map[string]*string{"hello": to.Ptr("world")},
	})
	handleError(err)
	fmt.Println(resp)

	queueClient := client.NewQueueClient("testqueue")

	// enqueue 4 messages
	for i := 0; i < 4; i++ {
		resp1, err := queueClient.EnqueueMessage(context.Background(), "test content", nil)
		handleError(err)
		fmt.Println(resp1)
	}
	// only check 3 messages
	opts := &azqueue.PeekMessagesOptions{NumberOfMessages: to.Ptr(int32(3))}
	resp2, err := queueClient.PeekMessages(context.Background(), opts)
	handleError(err)
	// check 3 messages retrieved
	fmt.Println(len(resp2.Messages))

	// delete the queue
	_, err = client.DeleteQueue(context.TODO(), "testqueue", nil)
	handleError(err)
	fmt.Println(resp)
}
Output:

Example (Client_Update_Message)
package main

import (
	"context"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/storage/azqueue"
	"log"
	"os"
)

func handleError(err error) {
	if err != nil {
		log.Fatal(err.Error())
	}
}

func main() {
	accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME")
	if !ok {
		panic("AZURE_STORAGE_ACCOUNT_NAME could not be found")
	}
	serviceURL := fmt.Sprintf("https://%s.queue.core.windows.net/", accountName)

	cred, err := azidentity.NewDefaultAzureCredential(nil)
	handleError(err)

	client, err := azqueue.NewServiceClient(serviceURL, cred, nil)
	handleError(err)

	resp, err := client.CreateQueue(context.TODO(), "testqueue", &azqueue.CreateOptions{
		Metadata: map[string]*string{"hello": to.Ptr("world")},
	})
	handleError(err)
	fmt.Println(resp)

	queueClient := client.NewQueueClient("testqueue")
	resp1, err := queueClient.EnqueueMessage(context.Background(), "test content", nil)
	handleError(err)
	fmt.Println(resp1)
	popReceipt := *resp1.Messages[0].PopReceipt
	messageID := *resp1.Messages[0].MessageID

	opts := &azqueue.UpdateMessageOptions{}
	_, err = queueClient.UpdateMessage(context.Background(), messageID, popReceipt, "new content", opts)
	handleError(err)

	resp3, err := queueClient.DequeueMessage(context.Background(), nil)
	handleError(err)
	// check message content has updated
	fmt.Println(resp3.Messages[0].MessageText)

	// delete the queue
	_, err = client.DeleteQueue(context.TODO(), "testqueue", nil)
	handleError(err)
	fmt.Println(resp)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessPolicy

type AccessPolicy = generated.AccessPolicy

AccessPolicy - An Access policy

type AccessPolicyPermission

type AccessPolicyPermission = exported.AccessPolicyPermission

AccessPolicyPermission type simplifies creating the permissions string for a queue's access policy. Initialize an instance of this type and then call its String method to set AccessPolicy's Permission field.

type CORSRule

type CORSRule = generated.CORSRule

CORSRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another domain. Web browsers implement a security restriction known as same-origin policy that prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin domain) to call APIs in another domain

type ClearMessagesOptions

type ClearMessagesOptions struct {
}

ClearMessagesOptions contains the optional parameters for the QueueClient.ClearMessages method.

type ClearMessagesResponse

type ClearMessagesResponse = generated.MessagesClientClearResponse

ClearMessagesResponse contains the response from method QueueClient.ClearMessages.

type ClientOptions

type ClientOptions struct {
	azcore.ClientOptions
}

ClientOptions contains the optional parameters when creating a ServiceClient or QueueClient.

type CreateOptions

type CreateOptions struct {
	// Optional. Specifies a user-defined name-value pair associated with the queue.
	Metadata map[string]*string
}

CreateOptions contains the optional parameters for creating a queue.

type CreateQueueResponse

type CreateQueueResponse = generated.QueueClientCreateResponse

CreateQueueResponse contains the response from method queue.ServiceClient.Create.

type CreateResponse

type CreateResponse = generated.QueueClientCreateResponse

CreateResponse contains the response from method QueueClient.Create.

type DeleteMessageOptions

type DeleteMessageOptions struct {
}

DeleteMessageOptions contains the optional parameters for the QueueClient.DeleteMessage method.

type DeleteMessageResponse

type DeleteMessageResponse = generated.MessageIDClientDeleteResponse

DeleteMessageResponse contains the response from method QueueClient.DeleteMessage.

type DeleteOptions

type DeleteOptions struct {
}

DeleteOptions contains the optional parameters for deleting a queue.

type DeleteQueueResponse

type DeleteQueueResponse = generated.QueueClientDeleteResponse

DeleteQueueResponse contains the response from method queue.ServiceClient.Delete

type DeleteResponse

type DeleteResponse = generated.QueueClientDeleteResponse

DeleteResponse contains the response from method QueueClient.Delete.

type DequeueMessageOptions

type DequeueMessageOptions struct {
	// If not specified, the default value is 0. Specifies the new visibility timeout value,
	// in seconds, relative to server time. The 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.
	VisibilityTimeout *int32
}

DequeueMessageOptions contains the optional parameters for the QueueClient.DequeueMessage method.

type DequeueMessagesOptions

type DequeueMessagesOptions struct {
	// Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue,
	// up to a maximum of 32. If fewer messages are visible, the visible messages are returned.
	// By default, a single message is retrieved from the queue with this operation.
	NumberOfMessages *int32
	// If not specified, the default value is 30. Specifies the
	// new visibility timeout value, in seconds, relative to server time.
	// The value must be larger than or equal to 1, 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.
	VisibilityTimeout *int32
}

DequeueMessagesOptions contains the optional parameters for the QueueClient.DequeueMessages method.

type DequeueMessagesResponse

type DequeueMessagesResponse = generated.MessagesClientDequeueResponse

DequeueMessagesResponse contains the response from method QueueClient.DequeueMessage or QueueClient.DequeueMessages.

type DequeuedMessage

type DequeuedMessage = generated.DequeuedMessage

DequeuedMessage - dequeued message

type EnqueueMessageOptions

type EnqueueMessageOptions struct {
	// Specifies the time-to-live interval for the message, in seconds.
	// The time-to-live may be any positive number or -1 for infinity.
	// If this parameter is omitted, the default time-to-live is 7 days.
	TimeToLive *int32
	// If not specified, the default value is 0.
	// Specifies the new visibility timeout value, in seconds, relative to server time.
	// The 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.
	VisibilityTimeout *int32
}

EnqueueMessageOptions contains the optional parameters for the QueueClient.EnqueueMessage method.

type EnqueueMessagesResponse

type EnqueueMessagesResponse = generated.MessagesClientEnqueueResponse

EnqueueMessagesResponse contains the response from method QueueClient.EnqueueMessage.

type EnqueuedMessage

type EnqueuedMessage = generated.EnqueuedMessage

EnqueuedMessage - enqueued message

type GeoReplication

type GeoReplication = generated.GeoReplication

GeoReplication - Geo-Replication information for the Secondary Storage Service

type GeoReplicationStatus

type GeoReplicationStatus = generated.GeoReplicationStatus

GeoReplicationStatus - The status of the secondary location

type GetAccessPolicyOptions

type GetAccessPolicyOptions struct {
}

GetAccessPolicyOptions contains the optional parameters for the QueueClient.GetAccessPolicy method.

type GetAccessPolicyResponse

type GetAccessPolicyResponse = generated.QueueClientGetAccessPolicyResponse

GetAccessPolicyResponse contains the response from method QueueClient.GetAccessPolicy.

type GetQueuePropertiesOptions

type GetQueuePropertiesOptions struct {
}

GetQueuePropertiesOptions contains the optional parameters for the QueueClient.GetProperties method.

type GetQueuePropertiesResponse

type GetQueuePropertiesResponse = generated.QueueClientGetPropertiesResponse

GetQueuePropertiesResponse contains the response from method QueueClient.GetProperties.

type GetSASURLOptions

type GetSASURLOptions struct {
	StartTime *time.Time
}

GetSASURLOptions contains the optional parameters for the Client.GetSASURL method.

type GetServicePropertiesOptions

type GetServicePropertiesOptions struct {
}

GetServicePropertiesOptions contains the optional parameters for the ServiceClient.GetServiceProperties method.

type GetServicePropertiesResponse

type GetServicePropertiesResponse = generated.ServiceClientGetPropertiesResponse

GetServicePropertiesResponse contains the response from method ServiceClient.GetServiceProperties.

type GetStatisticsOptions

type GetStatisticsOptions struct {
}

GetStatisticsOptions provides set of options for ServiceClient.GetStatistics

type GetStatisticsResponse

type GetStatisticsResponse = generated.ServiceClientGetStatisticsResponse

GetStatisticsResponse contains the response from method ServiceClient.GetStatistics.

type ListQueuesInclude

type ListQueuesInclude struct {
	// Tells the service whether to return metadata for each queue.
	Metadata bool
}

ListQueuesInclude indicates what additional information the service should return with each queue.

type ListQueuesOptions

type ListQueuesOptions struct {
	Include ListQueuesInclude

	// A string value that identifies the portion of the list of queues to be returned with the next listing operation. The
	// operation returns the NextMarker value within the response body if the listing operation did not return all queues
	// remaining to be listed with the current page. The NextMarker value can be used as the value for the marker parameter in
	// a subsequent call to request the next page of list items. The marker value is opaque to the client.
	Marker *string

	// Specifies the maximum number of queues to return. If the request does not specify max results, or specifies a value
	// greater than 5000, the server will return up to 5000 items. Note that if the listing operation crosses a partition boundary,
	// then the service will return a continuation token for retrieving the remainder of the results. For this reason, it is possible
	// that the service will return fewer results than specified by max results, or than the default of 5000.
	MaxResults *int32

	// Filters the results to return only queues whose name begins with the specified prefix.
	Prefix *string
}

ListQueuesOptions provides set of configurations for ListQueues operation

type ListQueuesResponse

ListQueuesResponse contains the response from method ServiceClient.ListQueuesSegment.

type ListQueuesSegmentResponse

type ListQueuesSegmentResponse = generated.ListQueuesSegmentResponse

ListQueuesSegmentResponse - response segment

type Logging

type Logging = generated.Logging

Logging - Azure Analytics Logging settings.

type Metrics

type Metrics = generated.Metrics

Metrics - a summary of request statistics grouped by API in hour or minute aggregates for queues

type PeekMessageOptions

type PeekMessageOptions struct {
}

PeekMessageOptions contains the optional parameters for the QueueClient.PeekMessage method.

type PeekMessagesOptions

type PeekMessagesOptions struct {
	NumberOfMessages *int32
}

PeekMessagesOptions contains the optional parameters for the QueueClient.PeekMessages method.

type PeekMessagesResponse

type PeekMessagesResponse = generated.MessagesClientPeekResponse

PeekMessagesResponse contains the response from method QueueClient.PeekMessage or QueueClient.PeekMessages.

type PeekedMessage

type PeekedMessage = generated.PeekedMessage

PeekedMessage - peeked message

type Queue

type Queue = generated.Queue

Queue - queue item

type QueueClient

QueueClient represents a URL to the Azure Queue Storage service allowing you to manipulate queues.

func NewQueueClient

func NewQueueClient(queueURL string, cred azcore.TokenCredential, options *ClientOptions) (*QueueClient, error)

NewQueueClient creates an instance of ServiceClient with the specified values.

  • serviceURL - the URL of the storage account e.g. https://<account>.queue.core.windows.net/
  • cred - an Azure AD credential, typically obtained via the azidentity module
  • options - client options; pass nil to accept the default values

func NewQueueClientFromConnectionString

func NewQueueClientFromConnectionString(connectionString string, queueName string, options *ClientOptions) (*QueueClient, error)

NewQueueClientFromConnectionString creates an instance of ServiceClient with the specified values.

  • connectionString - a connection string for the desired storage account
  • options - client options; pass nil to accept the default values

func NewQueueClientWithNoCredential

func NewQueueClientWithNoCredential(queueURL string, options *ClientOptions) (*QueueClient, error)

NewQueueClientWithNoCredential creates an instance of QueueClient with the specified values. This is used to anonymously access a storage account or with a shared access signature (SAS) token.

  • serviceURL - the URL of the storage account e.g. https://<account>.queue.core.windows.net/?<sas token>
  • options - client options; pass nil to accept the default values

func NewQueueClientWithSharedKeyCredential

func NewQueueClientWithSharedKeyCredential(queueURL string, cred *SharedKeyCredential, options *ClientOptions) (*QueueClient, error)

NewQueueClientWithSharedKeyCredential creates an instance of ServiceClient with the specified values.

  • serviceURL - the URL of the storage account e.g. https://<account>.queue.core.windows.net/
  • cred - a SharedKeyCredential created with the matching storage account and access key
  • options - client options; pass nil to accept the default values

func (*QueueClient) ClearMessages

ClearMessages deletes all messages from the queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/clear-messages.

func (*QueueClient) Create

func (q *QueueClient) Create(ctx context.Context, options *CreateOptions) (CreateResponse, error)

Create creates a new queue within a storage account. If a queue with the specified name already exists, and the existing metadata is identical to the metadata that's specified on the Create Queue request, status code 204 (No Content) is returned. If the existing metadata doesn't match the metadata provided with the Create Queue request, the operation fails and status code 409 (Conflict) is returned. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/create-queue4.

func (*QueueClient) Delete

func (q *QueueClient) Delete(ctx context.Context, options *DeleteOptions) (DeleteResponse, error)

Delete deletes the specified queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-queue3.

func (*QueueClient) DeleteMessage

func (q *QueueClient) DeleteMessage(ctx context.Context, messageID string, popReceipt string, o *DeleteMessageOptions) (DeleteMessageResponse, error)

DeleteMessage deletes message from queue with the given popReceipt. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-message2.

func (*QueueClient) DequeueMessage

DequeueMessage removes one message from the queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-messages.

func (*QueueClient) DequeueMessages

DequeueMessages removes one or more messages from the queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-messages.

func (*QueueClient) EnqueueMessage

func (q *QueueClient) EnqueueMessage(ctx context.Context, content string, o *EnqueueMessageOptions) (EnqueueMessagesResponse, error)

EnqueueMessage adds a message to the queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/put-message.

func (*QueueClient) GetAccessPolicy

GetAccessPolicy returns the queue's access policy. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-queue-acl.

func (*QueueClient) GetProperties

GetProperties gets properties including metadata of a queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/get-queue-metadata.

func (*QueueClient) GetSASURL

func (q *QueueClient) GetSASURL(permissions sas.QueuePermissions, expiry time.Time, o *GetSASURLOptions) (string, error)

GetSASURL is a convenience method for generating a SAS token for the currently pointed at account. It can only be used if the credential supplied during creation was a SharedKeyCredential. This validity can be checked with CanGetAccountSASToken().

func (*QueueClient) PeekMessage

PeekMessage peeks the first message from the queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/peek-messages.

func (*QueueClient) PeekMessages

PeekMessages peeks one or more messages from the queue For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/peek-messages.

func (*QueueClient) SetAccessPolicy

SetAccessPolicy sets the queue's permissions. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-queue-acl.

func (*QueueClient) SetMetadata

func (q *QueueClient) SetMetadata(ctx context.Context, options *SetMetadataOptions) (SetMetadataResponse, error)

SetMetadata sets the metadata for the queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/set-queue-metadata.

func (*QueueClient) URL

func (q *QueueClient) URL() string

URL returns the URL endpoint used by the ServiceClient object.

func (*QueueClient) UpdateMessage

func (q *QueueClient) UpdateMessage(ctx context.Context, messageID string, popReceipt string, content string, o *UpdateMessageOptions) (UpdateMessageResponse, error)

UpdateMessage updates a message from the queue with the given popReceipt. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/update-message.

type RetentionPolicy

type RetentionPolicy = generated.RetentionPolicy

RetentionPolicy - the retention policy which determines how long the associated data should persist

type ServiceClient

type ServiceClient base.Client[generated.ServiceClient]

ServiceClient represents a URL to the Azure Queue Storage service allowing you to manipulate queues.

func NewServiceClient

func NewServiceClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*ServiceClient, error)

NewServiceClient creates an instance of ServiceClient with the specified values.

  • serviceURL - the URL of the storage account e.g. https://<account>.queue.core.windows.net/
  • cred - an Azure AD credential, typically obtained via the azidentity module
  • options - client options; pass nil to accept the default values

func NewServiceClientFromConnectionString

func NewServiceClientFromConnectionString(connectionString string, options *ClientOptions) (*ServiceClient, error)

NewServiceClientFromConnectionString creates an instance of ServiceClient with the specified values.

  • connectionString - a connection string for the desired storage account
  • options - client options; pass nil to accept the default values

func NewServiceClientWithNoCredential

func NewServiceClientWithNoCredential(serviceURL string, options *ClientOptions) (*ServiceClient, error)

NewServiceClientWithNoCredential creates an instance of ServiceClient with the specified values. This is used to anonymously access a storage account or with a shared access signature (SAS) token.

  • serviceURL - the URL of the storage account e.g. https://<account>.queue.core.windows.net/?<sas token>
  • options - client options; pass nil to accept the default values

func NewServiceClientWithSharedKeyCredential

func NewServiceClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredential, options *ClientOptions) (*ServiceClient, error)

NewServiceClientWithSharedKeyCredential creates an instance of ServiceClient with the specified values.

  • serviceURL - the URL of the storage account e.g. https://<account>.queue.core.windows.net/
  • cred - a SharedKeyCredential created with the matching storage account and access key
  • options - client options; pass nil to accept the default values

func (*ServiceClient) CreateQueue

func (s *ServiceClient) CreateQueue(ctx context.Context, queueName string, options *CreateOptions) (CreateResponse, error)

CreateQueue creates a new queue within a storage account. If a queue with the same name already exists, the operation fails. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/create-queue4.

func (*ServiceClient) DeleteQueue

func (s *ServiceClient) DeleteQueue(ctx context.Context, queueName string, options *DeleteOptions) (DeleteResponse, error)

DeleteQueue deletes the specified queue. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-queue3.

func (*ServiceClient) GetSASURL

func (s *ServiceClient) GetSASURL(resources sas.AccountResourceTypes, permissions sas.AccountPermissions, expiry time.Time, o *GetSASURLOptions) (string, error)

GetSASURL is a convenience method for generating a SAS token for the currently pointed at account. It can only be used if the credential supplied during creation was a SharedKeyCredential. This validity can be checked with CanGetAccountSASToken().

func (*ServiceClient) GetServiceProperties

GetServiceProperties - gets the properties of a storage account's Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules.

func (*ServiceClient) GetStatistics

GetStatistics Retrieves statistics related to replication for the Queue service.

func (*ServiceClient) NewListQueuesPager

func (s *ServiceClient) NewListQueuesPager(o *ListQueuesOptions) *runtime.Pager[ListQueuesResponse]

NewListQueuesPager operation returns a pager of the queues under the specified account. Use an empty Marker to start enumeration from the beginning. Queue names are returned in lexicographic order. For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/list-queues1.

func (*ServiceClient) NewQueueClient

func (s *ServiceClient) NewQueueClient(queueName string) *QueueClient

NewQueueClient creates a new QueueClient object by concatenating queueName to the end of this Client's URL. The new QueueClient uses the same request policy pipeline as the Client.

func (*ServiceClient) SetProperties

SetProperties Sets the properties of a storage account's Queue service, including Azure Storage Analytics. If an element (e.g. analytics_logging) is left as None, the existing settings on the service for that functionality are preserved.

func (*ServiceClient) URL

func (s *ServiceClient) URL() string

URL returns the URL endpoint used by the ServiceClient object.

type SetAccessPolicyOptions

type SetAccessPolicyOptions struct {
	QueueACL []*SignedIdentifier
}

SetAccessPolicyOptions provides set of configurations for QueueClient.SetAccessPolicy operation

type SetAccessPolicyResponse

type SetAccessPolicyResponse = generated.QueueClientSetAccessPolicyResponse

SetAccessPolicyResponse contains the response from method QueueClient.SetAccessPolicy.

type SetMetadataOptions

type SetMetadataOptions struct {
	Metadata map[string]*string
}

SetMetadataOptions contains the optional parameters for the QueueClient.SetMetadata method.

type SetMetadataResponse

type SetMetadataResponse = generated.QueueClientSetMetadataResponse

SetMetadataResponse contains the response from method QueueClient.SetMetadata.

type SetPropertiesOptions

type SetPropertiesOptions struct {
	// The set of CORS rules.
	CORS []*CORSRule

	// a summary of request statistics grouped by API in hour or minute aggregates for queues
	HourMetrics *Metrics

	// Azure Analytics Logging settings.
	Logging *Logging

	// a summary of request statistics grouped by API in hour or minute aggregates for queues
	MinuteMetrics *Metrics
}

SetPropertiesOptions provides set of options for ServiceClient.SetProperties

type SetPropertiesResponse

type SetPropertiesResponse = generated.ServiceClientSetPropertiesResponse

SetPropertiesResponse contains the response from method ServiceClient.SetProperties.

type SharedKeyCredential

type SharedKeyCredential = exported.SharedKeyCredential

SharedKeyCredential contains an account's name and its primary or secondary key.

func NewSharedKeyCredential

func NewSharedKeyCredential(accountName, accountKey string) (*SharedKeyCredential, error)

NewSharedKeyCredential creates an immutable SharedKeyCredential containing the storage account's name and either its primary or secondary key.

type SignedIdentifier

type SignedIdentifier = generated.SignedIdentifier

SignedIdentifier - signed identifier

type StorageServiceProperties

type StorageServiceProperties = generated.StorageServiceProperties

StorageServiceProperties - Storage Service Properties.

type StorageServiceStats

type StorageServiceStats = generated.StorageServiceStats

StorageServiceStats - Stats for the storage service.

type URLParts

type URLParts = sas.URLParts

URLParts object represents the components that make up an Azure Storage Queue URL. NOTE: Changing any SAS-related field requires computing a new SAS signature.

func ParseURL

func ParseURL(u string) (URLParts, error)

ParseURL parses a URL initializing URLParts' fields including any SAS-related & snapshot query parameters. Any other query parameters remain in the UnparsedParams field. This method overwrites all fields in the URLParts object.

type UpdateMessageOptions

type UpdateMessageOptions struct {
	VisibilityTimeout *int32
}

UpdateMessageOptions contains the optional parameters for the QueueClient.UpdateMessage method.

type UpdateMessageResponse

type UpdateMessageResponse = generated.MessageIDClientUpdateResponse

UpdateMessageResponse contains the response from method QueueClient.UpdateMessage.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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