asbclient

package module
v0.0.0-...-96384dc Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2017 License: MIT Imports: 14 Imported by: 0

README

Azure Service Bus Client for Go

Golang client with methods to read and write data from ServiceBus queues and topics using REST.

See: https://docs.microsoft.com/en-us/rest/api/servicebus/Introduction

Godoc

Documentation

Overview

Package asbclient is a client for Azure Service Bus.

Index

Constants

This section is empty.

Variables

View Source
var ErrSubscriptionRequired = fmt.Errorf("A subscription is required for Service Bus Topic operations")

ErrSubscriptionRequired is raised when a service bus topics operations is performed without a subscription.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for Azure Service Bus (queues and topics). You should use a different client instance for every namespace. For more comprehensive documentation on its various methods, see:

https://msdn.microsoft.com/en-us/library/azure/hh780717.aspx

func New

func New(clientType ClientType, namespace string, sharedAccessKeyName string, sharedAccessKeyValue string) *Client

New creates a new client from the given parameters. Their meaning can be found in the MSDN docs at:

https://docs.microsoft.com/en-us/rest/api/servicebus/Introduction

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(item *Message) error

DeleteMessage deletes the message.

For more information see https://docs.microsoft.com/en-us/rest/api/servicebus/delete-message.

func (*Client) PeekLockMessage

func (c *Client) PeekLockMessage(path string, timeout int) (*Message, error)

PeekLockMessage atomically retrieves and locks the latest message from the queue or topic at `path` (which should not include slashes).

If using this with a service bus topic, make sure you SetSubscription() first. For more information see https://docs.microsoft.com/en-us/rest/api/servicebus/peek-lock-message-non-destructive-read.

func (*Client) Send

func (c *Client) Send(path string, item *Message) error

Send sends a new item to `path`, where `path` is either the queue name or the topic name.

For more information see https://docs.microsoft.com/en-us/rest/api/servicebus/send-message-to-queue.

func (*Client) SetSubscription

func (c *Client) SetSubscription(subscription string)

SetSubscription sets the client's subscription. Only required for Azure Service Bus Topics.

func (*Client) Unlock

func (c *Client) Unlock(item *Message) error

Unlock unlocks a message for processing by other receivers.

For more information see https://docs.microsoft.com/en-us/rest/api/servicebus/unlock-message.

type ClientType

type ClientType int

ClientType denotes the type of client (topic/queue) that is required

const (
	//Queue is a client type for Azure Service Bus queues
	Queue ClientType = iota

	//Topic is a client type for Azure Service Bus topics
	Topic ClientType = iota
)

type Error

type Error struct {
	Code   int
	Detail string
}

Error is the xml structure returned for errors

func (*Error) Error

func (e *Error) Error() string

type Message

type Message struct {
	DeliveryCount          int
	EnqueuedSequenceNumber int
	EnqueuedTimeUtc        Time
	LockToken              string
	LockedUntilUtc         Time
	MessageID              string `json:"MessageId"`
	PartitionKey           string
	SequenceNumber         int
	State                  string
	TimeToLive             int

	Location string

	Body []byte
}

Message is an Azure Service Bus message

type Time

type Time struct {
	time.Time
}

Time is a wrapper round time.Time to json encode/decode in RFC1123 fomat

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

MarshalJSON to RFC1123

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON from RFC1123

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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