rabbithole

package module
v2.6.11 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: BSD-2-Clause Imports: 14 Imported by: 0

README

Rabbit Hole, a RabbitMQ HTTP API Client for Go

This library is a RabbitMQ HTTP API client for the Go language.

Supported Go Versions

Rabbit Hole supports the last 2 stable Go versions, as well as the version in development (a.k.a. master).

Supported RabbitMQ Versions

  • RabbitMQ 3.8.x is the primary target series
  • Almost all API endpoints work against RabbitMQ 3.7.x nodes but some metrics and stats may be missing
  • RabbitMQ 3.7.x is out of general support

All versions require RabbitMQ Management UI plugin to be installed and enabled.

Project Maturity

Rabbit Hole is a mature library (first released in late 2013) designed after a couple of other RabbitMQ HTTP API clients with stable APIs. Breaking API changes are not out of the question but not without a reasonable version bump.

It is largely feature complete and decently documented.

Change Log

If upgrading from an earlier release, please consult with the change log.

Installation

go get github.com/michaelklishin/rabbit-hole/v2

# or, for v1.x:
# go get github.com/michaelklishin/rabbit-hole

Documentation

API Reference

API reference is available on godoc.org.

Continue reading for a list of example snippets.

Overview

To import the package:

import (
       "github.com/michaelklishin/rabbit-hole/v2"
)

All HTTP API operations are accessible via rabbithole.Client, which should be instantiated with rabbithole.NewClient:

// URI, username, password
rmqc, _ = NewClient("http://127.0.0.1:15672", "guest", "guest")

TLS (HTTPS) can be enabled by adding an HTTP transport to the parameters of rabbithole.NewTLSClient:

transport := &http.Transport{TLSClientConfig: tlsConfig}
rmqc, _ := NewTLSClient("https://127.0.0.1:15672", "guest", "guest", transport)

RabbitMQ HTTP API has to be configured to use TLS.

Getting Overview
res, err := rmqc.Overview()
Node and Cluster Status
xs, err := rmqc.ListNodes()
// => []NodeInfo, err

node, err := rmqc.GetNode("rabbit@mercurio")
// => NodeInfo, err
Operations on Connections
xs, err := rmqc.ListConnections()
// => []ConnectionInfo, err

conn, err := rmqc.GetConnection("127.0.0.1:50545 -> 127.0.0.1:5672")
// => ConnectionInfo, err

// Forcefully close connection
_, err := rmqc.CloseConnection("127.0.0.1:50545 -> 127.0.0.1:5672")
// => *http.Response, err
Operations on Channels
xs, err := rmqc.ListChannels()
// => []ChannelInfo, err

ch, err := rmqc.GetChannel("127.0.0.1:50545 -> 127.0.0.1:5672 (1)")
// => ChannelInfo, err
Operations on Vhosts
xs, err := rmqc.ListVhosts()
// => []VhostInfo, err

// information about individual vhost
x, err := rmqc.GetVhost("/")
// => VhostInfo, err

// creates or updates individual vhost
resp, err := rmqc.PutVhost("/", VhostSettings{Tracing: false})
// => *http.Response, err

// deletes individual vhost
resp, err := rmqc.DeleteVhost("/")
// => *http.Response, err
Managing Users
xs, err := rmqc.ListUsers()
// => []UserInfo, err

// information about individual user
x, err := rmqc.GetUser("my.user")
// => UserInfo, err

// creates or updates individual user
resp, err := rmqc.PutUser("my.user", UserSettings{Password: "s3krE7", Tags: "management,policymaker"})
// => *http.Response, err

// creates or updates individual user with no password
resp, err := rmqc.PutUserWithoutPassword("my.user", UserSettings{Tags: "management,policymaker"})
// => *http.Response, err

// deletes individual user
resp, err := rmqc.DeleteUser("my.user")
// => *http.Response, err
// creates or updates individual user with a Base64-encoded SHA256 password hash
hash := Base64EncodedSaltedPasswordHashSHA256("password-s3krE7")
resp, err := rmqc.PutUser("my.user", UserSettings{
  PasswordHash: hash,
  HashingAlgorithm: HashingAlgorithmSHA256,
  Tags: "management,policymaker"})
// => *http.Response, err
Managing Permissions
xs, err := rmqc.ListPermissions()
// => []PermissionInfo, err

// permissions of individual user
x, err := rmqc.ListPermissionsOf("my.user")
// => []PermissionInfo, err

// permissions of individual user in vhost
x, err := rmqc.GetPermissionsIn("/", "my.user")
// => PermissionInfo, err

// updates permissions of user in vhost
resp, err := rmqc.UpdatePermissionsIn("/", "my.user", Permissions{Configure: ".*", Write: ".*", Read: ".*"})
// => *http.Response, err

// revokes permissions in vhost
resp, err := rmqc.ClearPermissionsIn("/", "my.user")
// => *http.Response, err
Operations on Exchanges
xs, err := rmqc.ListExchanges()
// => []ExchangeInfo, err

// list exchanges in a vhost
xs, err := rmqc.ListExchangesIn("/")
// => []ExchangeInfo, err

// information about individual exchange
x, err := rmqc.GetExchange("/", "amq.fanout")
// => ExchangeInfo, err

// declares an exchange
resp, err := rmqc.DeclareExchange("/", "an.exchange", ExchangeSettings{Type: "fanout", Durable: false})
// => *http.Response, err

// deletes individual exchange
resp, err := rmqc.DeleteExchange("/", "an.exchange")
// => *http.Response, err
Operations on Queues
qs, err := rmqc.ListQueues()
// => []QueueInfo, err

// list queues in a vhost
qs, err := rmqc.ListQueuesIn("/")
// => []QueueInfo, err

// information about individual queue
q, err := rmqc.GetQueue("/", "a.queue")
// => QueueInfo, err

// declares a queue
resp, err := rmqc.DeclareQueue("/", "a.queue", QueueSettings{Durable: false})
// => *http.Response, err

// deletes individual queue
resp, err := rmqc.DeleteQueue("/", "a.queue")
// => *http.Response, err

// purges all messages in queue
resp, err := rmqc.PurgeQueue("/", "a.queue")
// => *http.Response, err

// synchronises all messages in queue with the rest of mirrors in the cluster
resp, err := rmqc.SyncQueue("/", "a.queue")
// => *http.Response, err

// cancels queue synchronisation process
resp, err := rmqc.CancelSyncQueue("/", "a.queue")
// => *http.Response, err
Operations on Bindings
bs, err := rmqc.ListBindings()
// => []BindingInfo, err

// list bindings in a vhost
bs, err := rmqc.ListBindingsIn("/")
// => []BindingInfo, err

// list bindings of a queue
bs, err := rmqc.ListQueueBindings("/", "a.queue")
// => []BindingInfo, err

// list all bindings having the exchange as source
bs1, err := rmqc.ListExchangeBindingsWithSource("/", "an.exchange")
// => []BindingInfo, err

// list all bindings having the exchange as destinattion
bs2, err := rmqc.ListExchangeBindingsWithDestination("/", "an.exchange")
// => []BindingInfo, err

// declare a binding
resp, err := rmqc.DeclareBinding("/", BindingInfo{
	Source: "an.exchange",
	Destination: "a.queue",
	DestinationType: "queue",
	RoutingKey: "#",
})
// => *http.Response, err

// deletes individual binding
resp, err := rmqc.DeleteBinding("/", BindingInfo{
	Source: "an.exchange",
	Destination: "a.queue",
	DestinationType: "queue",
	RoutingKey: "#",
	PropertiesKey: "%23",
})
// => *http.Response, err
Operations on Feature Flags
xs, err := rmqc.ListFeatureFlags()
// => []FeatureFlag, err

// enable a feature flag
_, err := rmqc.EnableFeatureFlag("drop_unroutable_metric")
// => *http.Response, err
Operations on Shovels
qs, err := rmqc.ListShovels()
// => []ShovelInfo, err

// list shovels in a vhost
qs, err := rmqc.ListShovelsIn("/")
// => []ShovelInfo, err

// information about an individual shovel
q, err := rmqc.GetShovel("/", "a.shovel")
// => ShovelInfo, err

// declares a shovel
shovelDetails := rabbithole.ShovelDefinition{
	SourceURI: "amqp://sourceURI",
	SourceProtocol: "amqp091",
	SourceQueue: "mySourceQueue",
	DestinationURI: "amqp://destinationURI",
	DestinationProtocol: "amqp10",
	DestinationAddress: "myDestQueue",
	DestinationAddForwardHeaders: true,
	AckMode: "on-confirm",
	SrcDeleteAfter: "never",
}
resp, err := rmqc.DeclareShovel("/", "a.shovel", shovelDetails)
// => *http.Response, err

// deletes an individual shovel
resp, err := rmqc.DeleteShovel("/", "a.shovel")
// => *http.Response, err

Operations on Runtime (vhost-scoped) Parameters
// list all runtime parameters
params, err := rmqc.ListRuntimeParameters()
// => []RuntimeParameter, error

// list all runtime parameters for a component
params, err := rmqc.ListRuntimeParametersFor("federation-upstream")
// => []RuntimeParameter, error

// list runtime parameters in a vhost
params, err := rmqc.ListRuntimeParametersIn("federation-upstream", "/")
// => []RuntimeParameter, error

// information about a runtime parameter
p, err := rmqc.GetRuntimeParameter("federation-upstream", "/", "name")
// => *RuntimeParameter, error

// declare or update a runtime parameter
resp, err := rmqc.PutRuntimeParameter("federation-upstream", "/", "name", FederationDefinition{
    Uri: "amqp://server-name",
})
// => *http.Response, error

// remove a runtime parameter
resp, err := rmqc.DeleteRuntimeParameter("federation-upstream", "/", "name")
// => *http.Response, error

Operations on Federation Upstreams
// list all federation upstreams
ups, err := rmqc.ListFederationUpstreams()
// => []FederationUpstream, error

// list federation upstreams in a vhost
ups, err := rmqc.ListFederationUpstreamsIn("/")
// => []FederationUpstream, error

// information about a federated upstream
up, err := rmqc.GetFederationUpstream("/", "name")
// => *FederationUpstream, error

// declare or update a federation upstream
resp, err := rmqc.PutFederationUpstream("/", "name", FederationDefinition{
  Uri: "amqp://server-name",
})
// => *http.Response, error

// delete an upstream
resp, err := rmqc.DeleteFederationUpstream("/", "name")
// => *http.Response, error

Operations on cluster name
// Get cluster name
cn, err := rmqc.GetClusterName()
// => ClusterName, err

// Rename cluster
resp, err := rmqc.SetClusterName(ClusterName{Name: "rabbitmq@rabbit-hole"})
// => *http.Response, err

HTTPS Connections
var tlsConfig *tls.Config

...

transport := &http.Transport{TLSClientConfig: tlsConfig}

rmqc, err := NewTLSClient("https://127.0.0.1:15672", "guest", "guest", transport)
Changing Transport Layer
var transport http.RoundTripper

...

rmqc.SetTransport(transport)

CI Status

Build Status

Contributing

See CONTRIBUTING.md

2-clause BSD license.

(c) Michael S. Klishin and contributors, 2013-2020.

Documentation

Overview

Package rabbithole is a Go client for the RabbitMQ HTTP API.

All HTTP API operations are accessible via `rabbithole.Client`, which should be instantiated with `rabbithole.NewClient`.

// URI, username, password
rmqc, _ = NewClient("http://127.0.0.1:15672", "guest", "guest")

Getting Overview

res, err := rmqc.Overview()

Node and Cluster Status

var err error

// => []NodeInfo, err
xs, err := rmqc.ListNodes()

node, err := rmqc.GetNode("rabbit@mercurio")
// => NodeInfo, err

Operations on Connections

xs, err := rmqc.ListConnections()
// => []ConnectionInfo, err

conn, err := rmqc.GetConnection("127.0.0.1:50545 -> 127.0.0.1:5672")
// => ConnectionInfo, err

// Forcefully close connection
_, err := rmqc.CloseConnection("127.0.0.1:50545 -> 127.0.0.1:5672")
// => *http.Response, err

Operations on Channels

xs, err := rmqc.ListChannels()
// => []ChannelInfo, err

ch, err := rmqc.GetChannel("127.0.0.1:50545 -> 127.0.0.1:5672 (1)")
// => ChannelInfo, err

Operations on Exchanges

xs, err := rmqc.ListExchanges()
// => []ExchangeInfo, err

// list exchanges in a vhost
xs, err := rmqc.ListExchangesIn("/")
// => []ExchangeInfo, err

// information about individual exchange
x, err := rmqc.GetExchange("/", "amq.fanout")
// => ExchangeInfo, err

// declares an exchange
resp, err := rmqc.DeclareExchange("/", "an.exchange", ExchangeSettings{Type: "fanout", Durable: false})
// => *http.Response, err

// deletes individual exchange
resp, err := rmqc.DeleteExchange("/", "an.exchange")
// => *http.Response, err

Operations on Queues

xs, err := rmqc.ListQueues()
// => []QueueInfo, err

// list queues in a vhost
xs, err := rmqc.ListQueuesIn("/")
// => []QueueInfo, err

// information about individual queue
x, err := rmqc.GetQueue("/", "a.queue")
// => QueueInfo, err

// declares a queue
resp, err := rmqc.DeclareQueue("/", "a.queue", QueueSettings{Durable: false})
// => *http.Response, err

// deletes individual queue
resp, err := rmqc.DeleteQueue("/", "a.queue")
// => *http.Response, err

// purges all messages in queue
resp, err := rmqc.PurgeQueue("/", "a.queue")
// => *http.Response, err

Operations on Bindings

bs, err := rmqc.ListBindings()
// => []BindingInfo, err

// list bindings in a vhost
bs, err := rmqc.ListBindingsIn("/")
// => []BindingInfo, err

// list bindings of a queue
bs, err := rmqc.ListQueueBindings("/", "a.queue")
// => []BindingInfo, err

// declare a binding
resp, err := rmqc.DeclareBinding("/", BindingInfo{
    Source: "an.exchange",
    Destination: "a.queue",
    DestinationType: "queue",
    RoutingKey: "#",
})
// => *http.Response, err

// deletes individual binding
resp, err := rmqc.DeleteBinding("/", BindingInfo{
    Source: "an.exchange",
    Destination: "a.queue",
    DestinationType: "queue",
    RoutingKey: "#",
    PropertiesKey: "%23",
})
// => *http.Response, err

Operations on Vhosts

xs, err := rmqc.ListVhosts()
// => []VhostInfo, err

// information about individual vhost
x, err := rmqc.GetVhost("/")
// => VhostInfo, err

// creates or updates individual vhost
resp, err := rmqc.PutVhost("/", VhostSettings{Tracing: false})
// => *http.Response, err

// deletes individual vhost
resp, err := rmqc.DeleteVhost("/")
// => *http.Response, err

Managing Users

xs, err := rmqc.ListUsers()
// => []UserInfo, err

// information about individual user
x, err := rmqc.GetUser("my.user")
// => UserInfo, err

// creates or updates individual user
resp, err := rmqc.PutUser("my.user", UserSettings{Password: "s3krE7", Tags: "management policymaker"})
// => *http.Response, err

// deletes individual user
resp, err := rmqc.DeleteUser("my.user")
// => *http.Response, err

Managing Permissions

xs, err := rmqc.ListPermissions()
// => []PermissionInfo, err

// permissions of individual user
x, err := rmqc.ListPermissionsOf("my.user")
// => []PermissionInfo, err

// permissions of individual user in vhost
x, err := rmqc.GetPermissionsIn("/", "my.user")
// => PermissionInfo, err

// updates permissions of user in vhost
resp, err := rmqc.UpdatePermissionsIn("/", "my.user", Permissions{Configure: ".*", Write: ".*", Read: ".*"})
// => *http.Response, err

// revokes permissions in vhost
resp, err := rmqc.ClearPermissionsIn("/", "my.user")
// => *http.Response, err

Managing Topic Permissions

xs, err := rmqc.ListTopicPermissions()
// => []TopicPermissionInfo, err

// permissions of individual user
x, err := rmqc.ListTopicPermissionsOf("my.user")
// => []TopicPermissionInfo, err

// permissions of individual user in vhost
x, err := rmqc.GetTopicPermissionsIn("/", "my.user")
// => []TopicPermissionInfo, err

// updates permissions of user in vhost
resp, err := rmqc.UpdateTopicPermissionsIn("/", "my.user", Permissions{Exchange: "amq.topic", Write: ".*", Read: ".*"})
// => *http.Response, err

// revokes permissions in vhost
resp, err := rmqc.ClearTopicPermissionsIn("/", "my.user")
// => *http.Response, err

// revokes single permissions in vhost
resp, err := rmqc.DeleteTopicPermissionsIn("/", "my.user", "exchange")
// => *http.Response, err

Managing Runtime Parameters

// list all runtime parameters
params, err := rmqc.ListRuntimeParameters()
// => []RuntimeParameter, error

// list all runtime parameters for a component
params, err := rmqc.ListRuntimeParametersFor("federation-upstream")
// => []RuntimeParameter, error

// list runtime parameters in a vhost
params, err := rmqc.ListRuntimeParametersIn("federation-upstream", "/")
// => []RuntimeParameter, error

// information about a runtime parameter
p, err := rmqc.GetRuntimeParameter("federation-upstream", "/", "name")
// => *RuntimeParameter, error

// declare or update a runtime parameter
resp, err := rmqc.PutRuntimeParameter("federation-upstream", "/", "name", FederationDefinition{
    Uri: "amqp://server-name",
})
// => *http.Response, error

// remove a runtime parameter
resp, err := rmqc.DeleteRuntimeParameter("federation-upstream", "/", "name")
// => *http.Response, error

Managing Federation Upstreams

// list all federation upstreams
ups, err := rmqc.ListFederationUpstreams()
// => []FederationUpstream, error

// list federation upstreams in a vhost
ups, err := rmqc.ListFederationUpstreamsIn("/")
// => []FederationUpstream, error

// information about a federated upstream
up, err := rmqc.GetFederationUpstream("/", "upstream-name")
// => *FederationUpstream, error

// declare or update a federation upstream
resp, err := rmqc.PutFederationUpstream("/", "upstream-name", FederationDefinition{
  Uri: "amqp://server-name",
})
// => *http.Response, error

// delete an upstream
resp, err := rmqc.DeleteFederationUpstream("/", "upstream-name")
// => *http.Response, error

Operations on cluster name

// Get cluster name
cn, err := rmqc.GetClusterName()
// => ClusterName, err

// Rename cluster
resp, err := rmqc.SetClusterName(ClusterName{Name: "rabbitmq@rabbit-hole"})
// => *http.Response, err

Index

Constants

View Source
const FederationUpstreamComponent string = "federation-upstream"

FederationUpstreamComponent is the name of the runtime parameter component used by federation upstreams.

Variables

This section is empty.

Functions

func Base64EncodedSaltedPasswordHashSHA256

func Base64EncodedSaltedPasswordHashSHA256(password string) string

Base64EncodedSaltedPasswordHashSHA256 produces a salted hash value expected by the HTTP API. See https://www.rabbitmq.com/passwords.html#computing-password-hash for details.

func Base64EncodedSaltedPasswordHashSHA512

func Base64EncodedSaltedPasswordHashSHA512(password string) string

Base64EncodedSaltedPasswordHashSHA512 produces a salted hash value expected by the HTTP API. See https://www.rabbitmq.com/passwords.html#computing-password-hash for details.

func GenerateSalt

func GenerateSalt(n int) string

GenerateSalt generates a password salt. Used to compute password hashes when creating or updating user information. See https://www.rabbitmq.com/passwords.html#computing-password-hash for details.

func SaltedPasswordHashSHA256

func SaltedPasswordHashSHA256(password string) (string, string)

SaltedPasswordHashSHA256 is used to compute SHA-256 password hashes when creating or updating user information. See https://www.rabbitmq.com/passwords.html#computing-password-hash for details.

func SaltedPasswordHashSHA512

func SaltedPasswordHashSHA512(password string) (string, string)

SaltedPasswordHashSHA512 is used to compute SHA-512 password hashes when creating or updating user information. See https://www.rabbitmq.com/passwords.html#computing-password-hash for details.

Types

type AcknowledgementMode

type AcknowledgementMode bool

AcknowledgementMode specifies an acknowledgement mode used by a consumer. Learn more at https://www.rabbitmq.com/confirms.html.

const (
	// ManualAcknowledgement requires the consumer to explicitly
	// acknowledge processed deliveries.
	ManualAcknowledgement AcknowledgementMode = true
	// AutomaticAcknowledgment means that deliveries sent
	// to the consumer will be considered processed immediately.
	// Explicit acks from the client are not needed or expected
	// by the server.
	AutomaticAcknowledgment AcknowledgementMode = false
)

type AuthMechanism

type AuthMechanism NameDescriptionEnabled

AuthMechanism is a RabbbitMQ authentication and/or authorization mechanism available on the node.

type BackingQueueStatus

type BackingQueueStatus struct {
	Q1 int `json:"q1"`
	Q2 int `json:"q2"`
	Q3 int `json:"q3"`
	Q4 int `json:"q4"`
	// Total queue length
	Length int64 `json:"len"`
	// Number of pending acks from consumers
	PendingAcks int64 `json:"pending_acks"`
	// Number of messages held in RAM
	RAMMessageCount int64 `json:"ram_msg_count"`
	// Number of outstanding acks held in RAM
	RAMAckCount int64 `json:"ram_ack_count"`
	// Number of persistent messages in the store
	PersistentCount int64 `json:"persistent_count"`
	// Average ingress (inbound) rate, not including messages
	// that straight through to auto-acking consumers.
	AverageIngressRate float64 `json:"avg_ingress_rate"`
	// Average egress (outbound) rate, not including messages
	// that straight through to auto-acking consumers.
	AverageEgressRate float64 `json:"avg_egress_rate"`
	// rate at which unacknowledged message records enter RAM,
	// e.g. because messages are delivered requiring acknowledgement
	AverageAckIngressRate float32 `json:"avg_ack_ingress_rate"`
	// rate at which unacknowledged message records leave RAM,
	// e.g. because acks arrive or unacked messages are paged out
	AverageAckEgressRate float32 `json:"avg_ack_egress_rate"`
}

BackingQueueStatus exposes backing queue (queue storage engine) metrics. They can change in a future version of RabbitMQ.

type BindingInfo

type BindingInfo struct {
	// Binding source (exchange name)
	Source string `json:"source"`
	Vhost  string `json:"vhost"`
	// Binding destination (queue or exchange name)
	Destination string `json:"destination"`
	// Destination type, either "queue" or "exchange"
	DestinationType string                 `json:"destination_type"`
	RoutingKey      string                 `json:"routing_key"`
	Arguments       map[string]interface{} `json:"arguments"`
	PropertiesKey   string                 `json:"properties_key"`
}

BindingInfo represents details of a binding.

type BindingVertex

type BindingVertex string

BindingVertex represents one end (vertex) of a binding, a source or destination. This is primarily relevant for exchange-to-exchange bindings (E2Es).

const (
	// BindingSource indicates the source vertex of a binding
	BindingSource BindingVertex = "source"
	// BindingDestination indicates the source vertex of a binding
	BindingDestination BindingVertex = "destination"
)

func (BindingVertex) String

func (v BindingVertex) String() string

type BriefChannelDetail

type BriefChannelDetail struct {
	ConnectionName string `json:"connection_name"`
	Name           string `json:"name"`
	Node           string `json:"node"`
	Number         int    `json:"number"`
	PeerHost       string `json:"peer_host"`
	PeerPort       int    `json:"peer_port"`
	User           string `json:"user"`
}

BriefChannelDetail represents a channel with a limited number of metrics.

type BriefConnectionDetails

type BriefConnectionDetails struct {
	// Connection name
	Name string `json:"name"`
	// Client port
	PeerPort Port `json:"peer_port"`
	// Client host
	PeerHost string `json:"peer_host"`
}

BriefConnectionDetails represents a brief (very incomplete) subset of connection information.

type BriefQueueInfo

type BriefQueueInfo struct {
	Name  string `json:"name"`
	Vhost string `json:"vhost"`
}

BriefQueueInfo represents a fully qualified queue name.

type BrokerContext

type BrokerContext struct {
	Node        string `json:"node"`
	Description string `json:"description"`
	Path        string `json:"path"`
	Port        Port   `json:"port"`
	Ignore      bool   `json:"ignore_in_use"`
}

BrokerContext represents a context (Erlang application) running on a node a node

type ChannelInfo

type ChannelInfo struct {
	// Channel number
	Number int `json:"number"`
	// Channel name
	Name string `json:"name"`

	// basic.qos (prefetch count) value used
	PrefetchCount int `json:"prefetch_count"`
	// How many consumers does this channel have
	ConsumerCount int `json:"consumer_count"`

	// Number of unacknowledged messages on this channel
	UnacknowledgedMessageCount int `json:"messages_unacknowledged"`
	// Number of messages on this channel unconfirmed to publishers
	UnconfirmedMessageCount int `json:"messages_unconfirmed"`
	// Number of messages on this channel uncommited to message store
	UncommittedMessageCount int `json:"messages_uncommitted"`
	// Number of acks on this channel uncommited to message store
	UncommittedAckCount int `json:"acks_uncommitted"`

	// TODO(mk): custom deserializer to date/time?
	IdleSince string `json:"idle_since"`

	// True if this channel uses publisher confirms
	UsesPublisherConfirms bool `json:"confirm"`
	// True if this channel uses transactions
	Transactional bool `json:"transactional"`
	// True if this channel is blocked via channel.flow
	ClientFlowBlocked bool `json:"client_flow_blocked"`

	User  string `json:"user"`
	Vhost string `json:"vhost"`
	Node  string `json:"node"`

	ConnectionDetails BriefConnectionDetails `json:"connection_details"`
}

ChannelInfo represents an AMQP 0-9-1 channel.

type Client

type Client struct {
	// URI of a RabbitMQ node to use, not including the path, e.g. http://127.0.0.1:15672.
	Endpoint string
	// Username to use. This RabbitMQ user must have the "management" tag.
	Username string
	// Password to use.
	Password string
	// contains filtered or unexported fields
}

Client for interaction with RabbitMQ HTTP API.

func NewClient

func NewClient(uri string, username string, password string) (me *Client, err error)

NewClient instantiates a client.

func NewTLSClient

func NewTLSClient(uri string, username string, password string, transport http.RoundTripper) (me *Client, err error)

NewTLSClient instantiates a client with a transport; it is up to the developer to make that layer secure.

func (*Client) CancelSyncQueue

func (c *Client) CancelSyncQueue(vhost, queue string) (res *http.Response, err error)

CancelSyncQueue cancels queue synchronisation process.

func (*Client) ClearPermissionsIn

func (c *Client) ClearPermissionsIn(vhost, username string) (res *http.Response, err error)

ClearPermissionsIn clears (deletes) permissions of user in virtual host.

func (*Client) ClearTopicPermissionsIn

func (c *Client) ClearTopicPermissionsIn(vhost, username string) (res *http.Response, err error)

ClearTopicPermissionsIn clears (deletes) topic-permissions of user in virtual host.

func (*Client) CloseConnection

func (c *Client) CloseConnection(name string) (res *http.Response, err error)

CloseConnection closes a connection.

func (*Client) DeclareBinding

func (c *Client) DeclareBinding(vhost string, info BindingInfo) (res *http.Response, err error)

DeclareBinding adds a new binding

func (*Client) DeclareExchange

func (c *Client) DeclareExchange(vhost, exchange string, info ExchangeSettings) (res *http.Response, err error)

DeclareExchange declares an exchange.

func (*Client) DeclareQueue

func (c *Client) DeclareQueue(vhost, queue string, info QueueSettings) (res *http.Response, err error)

DeclareQueue declares a queue.

func (*Client) DeclareShovel

func (c *Client) DeclareShovel(vhost, shovel string, info ShovelDefinition) (res *http.Response, err error)

DeclareShovel creates a shovel

func (*Client) DeleteAllRuntimeParameters

func (c *Client) DeleteAllRuntimeParameters() (err error)

DeleteAllRuntimeParameters clears all runtime parameters. Only mean to be used in integration tests.

func (*Client) DeleteBinding

func (c *Client) DeleteBinding(vhost string, info BindingInfo) (res *http.Response, err error)

DeleteBinding delets an individual binding

func (*Client) DeleteExchange

func (c *Client) DeleteExchange(vhost, exchange string) (res *http.Response, err error)

DeleteExchange deletes an exchange.

func (*Client) DeleteFederationUpstream

func (c *Client) DeleteFederationUpstream(vhost, name string) (res *http.Response, err error)

DeleteFederationUpstream removes a federation upstream.

func (*Client) DeletePolicy

func (c *Client) DeletePolicy(vhost, name string) (res *http.Response, err error)

DeletePolicy deletes a policy.

func (*Client) DeleteQueue

func (c *Client) DeleteQueue(vhost, queue string, opts ...QueueDeleteOptions) (res *http.Response, err error)

DeleteQueue deletes a queue.

func (*Client) DeleteRuntimeParameter

func (c *Client) DeleteRuntimeParameter(component, vhost, name string) (res *http.Response, err error)

DeleteRuntimeParameter removes a runtime parameter.

func (*Client) DeleteShovel

func (c *Client) DeleteShovel(vhost, shovel string) (res *http.Response, err error)

DeleteShovel a shovel

func (*Client) DeleteTopicPermissionsIn

func (c *Client) DeleteTopicPermissionsIn(vhost, username string, exchange string) (res *http.Response, err error)

DeleteTopicPermissionsIn delete topic-permissions of exchange for user in virtual host.

func (*Client) DeleteUser

func (c *Client) DeleteUser(username string) (res *http.Response, err error)

DeleteUser deletes a user by name.

func (*Client) DeleteVhost

func (c *Client) DeleteVhost(vhostname string) (res *http.Response, err error)

DeleteVhost deletes a virtual host.

func (*Client) EnableFeatureFlag

func (c *Client) EnableFeatureFlag(featureFlagName string) (res *http.Response, err error)

EnableFeatureFlag enables a feature flag.

func (*Client) EnabledProtocols

func (c *Client) EnabledProtocols() (xs []string, err error)

EnabledProtocols returns a list of names of the plugins enabled on target node.

func (*Client) GetChannel

func (c *Client) GetChannel(name string) (rec *ChannelInfo, err error)

GetChannel returns channel information.

func (*Client) GetClusterName

func (c *Client) GetClusterName() (rec *ClusterName, err error)

GetClusterName returns current cluster name.

func (*Client) GetConnection

func (c *Client) GetConnection(name string) (rec *ConnectionInfo, err error)

GetConnection retrieves information about a connection.

func (*Client) GetExchange

func (c *Client) GetExchange(vhost, exchange string) (rec *DetailedExchangeInfo, err error)

GetExchange returns information about an exchange.

func (*Client) GetFederationUpstream

func (c *Client) GetFederationUpstream(vhost, name string) (up *FederationUpstream, err error)

GetFederationUpstream returns information about a federation upstream.

func (*Client) GetNode

func (c *Client) GetNode(name string) (rec *NodeInfo, err error)

GetNode return information about a node.

func (*Client) GetPermissionsIn

func (c *Client) GetPermissionsIn(vhost, username string) (rec PermissionInfo, err error)

GetPermissionsIn returns permissions of user in virtual host.

func (*Client) GetPolicy

func (c *Client) GetPolicy(vhost, name string) (rec *Policy, err error)

GetPolicy returns individual policy in virtual host.

func (*Client) GetQueue

func (c *Client) GetQueue(vhost, queue string) (rec *DetailedQueueInfo, err error)

GetQueue returns information about a queue.

func (*Client) GetQueueWithParameters

func (c *Client) GetQueueWithParameters(vhost, queue string, qs url.Values) (rec *DetailedQueueInfo, err error)

GetQueueWithParameters returns information about a queue. Compared to the regular GetQueue function, this one accepts additional query string values.

func (*Client) GetRuntimeParameter

func (c *Client) GetRuntimeParameter(component, vhost, name string) (p *RuntimeParameter, err error)

GetRuntimeParameter returns information about a runtime parameter.

func (*Client) GetShovel

func (c *Client) GetShovel(vhost, shovel string) (rec *ShovelInfo, err error)

GetShovel returns a shovel configuration

func (*Client) GetTopicPermissionsIn

func (c *Client) GetTopicPermissionsIn(vhost, username string) (rec []TopicPermissionInfo, err error)

GetTopicPermissionsIn returns topic-permissions of user in virtual host.

func (*Client) GetUser

func (c *Client) GetUser(username string) (rec *UserInfo, err error)

GetUser returns information about individual user.

func (*Client) GetVhost

func (c *Client) GetVhost(vhostname string) (rec *VhostInfo, err error)

GetVhost returns information about a specific virtual host.

func (*Client) ListBindings

func (c *Client) ListBindings() (rec []BindingInfo, err error)

ListBindings returns all bindings

func (*Client) ListBindingsIn

func (c *Client) ListBindingsIn(vhost string) (rec []BindingInfo, err error)

ListBindingsIn returns all bindings in a virtual host.

func (*Client) ListChannels

func (c *Client) ListChannels() (rec []ChannelInfo, err error)

ListChannels returns information about all open channels.

func (*Client) ListConnections

func (c *Client) ListConnections() (rec []ConnectionInfo, err error)

ListConnections returns a list of client connections to target node.

func (*Client) ListConsumers

func (c *Client) ListConsumers() (rec []ConsumerInfo, err error)

ListConsumers lists all consumers in the cluster.

func (*Client) ListConsumersIn

func (c *Client) ListConsumersIn(vhost string) (rec []ConsumerInfo, err error)

ListConsumersIn lists all consumers in a virtual host.

func (*Client) ListDefinitions added in v2.6.11

func (c *Client) ListDefinitions() (p *ExportedDefinitions, err error)

ListDefinitions returns a set of definitions exported from a RabbitMQ cluster.

func (*Client) ListExchangeBindings

func (c *Client) ListExchangeBindings(vhost, exchange string, sourceOrDestination BindingVertex) (rec []BindingInfo, err error)

ListExchangeBindings returns all bindings having the exchange as source or destination as defined by the Target

func (*Client) ListExchangeBindingsBetween

func (c *Client) ListExchangeBindingsBetween(vhost, source string, destination string) (rec []BindingInfo, err error)

ListExchangeBindingsBetween returns a set of bindings between two exchanges.

func (*Client) ListExchangeBindingsWithDestination

func (c *Client) ListExchangeBindingsWithDestination(vhost, exchange string) (rec []BindingInfo, err error)

ListExchangeBindingsWithDestination returns exchange-to-exchange (E2E) bindings where the given exchange is the destination.

func (*Client) ListExchangeBindingsWithSource

func (c *Client) ListExchangeBindingsWithSource(vhost, exchange string) (rec []BindingInfo, err error)

ListExchangeBindingsWithSource returns exchange-to-exchange (E2E) bindings where the given exchange is the source.

func (*Client) ListExchanges

func (c *Client) ListExchanges() (rec []ExchangeInfo, err error)

ListExchanges lists all exchanges in a cluster. This only includes exchanges in the virtual hosts accessible to the user.

func (*Client) ListExchangesIn

func (c *Client) ListExchangesIn(vhost string) (rec []ExchangeInfo, err error)

ListExchangesIn lists all exchanges in a virtual host.

func (*Client) ListFeatureFlags

func (c *Client) ListFeatureFlags() (rec []FeatureFlag, err error)

ListFeatureFlags lists all feature flags.

func (c *Client) ListFederationLinks() (links []map[string]interface{}, err error)

ListFederationLinks returns a list of all federation links.

func (*Client) ListFederationLinksIn

func (c *Client) ListFederationLinksIn(vhost string) (links []map[string]interface{}, err error)

ListFederationLinksIn returns a list of federation links in a vhost.

func (*Client) ListFederationUpstreams

func (c *Client) ListFederationUpstreams() (ups []FederationUpstream, err error)

ListFederationUpstreams returns a list of all federation upstreams.

func (*Client) ListFederationUpstreamsIn

func (c *Client) ListFederationUpstreamsIn(vhost string) (ups []FederationUpstream, err error)

ListFederationUpstreamsIn returns a list of all federation upstreams in a vhost.

func (*Client) ListNodes

func (c *Client) ListNodes() (rec []NodeInfo, err error)

ListNodes returns a list of cluster nodes.

func (*Client) ListPermissions

func (c *Client) ListPermissions() (rec []PermissionInfo, err error)

ListPermissions returns permissions for all users and virtual hosts.

func (*Client) ListPermissionsOf

func (c *Client) ListPermissionsOf(username string) (rec []PermissionInfo, err error)

ListPermissionsOf returns permissions of a specific user.

func (*Client) ListPolicies

func (c *Client) ListPolicies() (rec []Policy, err error)

ListPolicies returns all policies (across all virtual hosts).

func (*Client) ListPoliciesIn

func (c *Client) ListPoliciesIn(vhost string) (rec []Policy, err error)

ListPoliciesIn returns policies in a specific virtual host.

func (*Client) ListQueueBindings

func (c *Client) ListQueueBindings(vhost, queue string) (rec []BindingInfo, err error)

ListQueueBindings returns all bindings of individual queue.

func (*Client) ListQueueBindingsBetween

func (c *Client) ListQueueBindingsBetween(vhost, exchange string, queue string) (rec []BindingInfo, err error)

ListQueueBindingsBetween returns a set of bindings between an exchange and a queue.

func (*Client) ListQueues

func (c *Client) ListQueues() (rec []QueueInfo, err error)

ListQueues lists all queues in the cluster. This only includes queues in the virtual hosts accessible to the user.

func (*Client) ListQueuesIn

func (c *Client) ListQueuesIn(vhost string) (rec []QueueInfo, err error)

ListQueuesIn lists all queues in a virtual host.

func (*Client) ListQueuesWithParameters

func (c *Client) ListQueuesWithParameters(params url.Values) (rec []QueueInfo, err error)

ListQueuesWithParameters lists queues with a list of query string values.

func (*Client) ListRuntimeParameters

func (c *Client) ListRuntimeParameters() (params []RuntimeParameter, err error)

ListRuntimeParameters returns a list of all runtime parameters.

func (*Client) ListRuntimeParametersFor

func (c *Client) ListRuntimeParametersFor(component string) (params []RuntimeParameter, err error)

ListRuntimeParametersFor returns a list of all runtime parameters for a component in all vhosts.

func (*Client) ListRuntimeParametersIn

func (c *Client) ListRuntimeParametersIn(component, vhost string) (p []RuntimeParameter, err error)

ListRuntimeParametersIn returns a list of all runtime parameters for a component in a vhost.

func (*Client) ListShovels

func (c *Client) ListShovels() (rec []ShovelInfo, err error)

ListShovels returns all shovels

func (*Client) ListShovelsIn

func (c *Client) ListShovelsIn(vhost string) (rec []ShovelInfo, err error)

ListShovelsIn returns all shovels in a vhost

func (*Client) ListTopicPermissions

func (c *Client) ListTopicPermissions() (rec []TopicPermissionInfo, err error)

ListTopicPermissions returns topic-permissions for all users and virtual hosts.

func (*Client) ListTopicPermissionsOf

func (c *Client) ListTopicPermissionsOf(username string) (rec []TopicPermissionInfo, err error)

ListTopicPermissionsOf returns topic-permissions of a specific user.

func (*Client) ListUsers

func (c *Client) ListUsers() (rec []UserInfo, err error)

ListUsers returns a list of all users in a cluster.

func (*Client) ListVhosts

func (c *Client) ListVhosts() (rec []VhostInfo, err error)

ListVhosts returns a list of virtual hosts.

func (*Client) Overview

func (c *Client) Overview() (rec *Overview, err error)

Overview returns an overview of cluster state with some key aggregated metrics.

func (*Client) PagedListQueuesWithParameters

func (c *Client) PagedListQueuesWithParameters(params url.Values) (rec PagedQueueInfo, err error)

PagedListQueuesWithParameters lists queues with pagination.

func (*Client) ProtocolPorts

func (c *Client) ProtocolPorts() (res map[string]Port, err error)

ProtocolPorts returns a list of active (listening) ports on target node.

func (*Client) PurgeQueue

func (c *Client) PurgeQueue(vhost, queue string) (res *http.Response, err error)

PurgeQueue purges a queue (deletes all messages ready for delivery in it).

func (*Client) PutFederationUpstream

func (c *Client) PutFederationUpstream(vhost, name string, def FederationDefinition) (res *http.Response, err error)

PutFederationUpstream creates or updates a federation upstream configuration.

func (*Client) PutPolicy

func (c *Client) PutPolicy(vhost string, name string, policy Policy) (res *http.Response, err error)

PutPolicy creates or updates a policy.

func (*Client) PutRuntimeParameter

func (c *Client) PutRuntimeParameter(component, vhost, name string, value interface{}) (res *http.Response, err error)

PutRuntimeParameter creates or updates a runtime parameter.

func (*Client) PutUser

func (c *Client) PutUser(username string, info UserSettings) (res *http.Response, err error)

PutUser updates information about an individual user.

func (*Client) PutUserWithoutPassword

func (c *Client) PutUserWithoutPassword(username string, info UserSettings) (res *http.Response, err error)

PutUserWithoutPassword creates a passwordless user. Such users can only authenticate using an X.509 certificate or another authentication mechanism (or backend) that does not use passwords.

func (*Client) PutVhost

func (c *Client) PutVhost(vhostname string, settings VhostSettings) (res *http.Response, err error)

PutVhost creates or updates a virtual host.

func (*Client) SetClusterName

func (c *Client) SetClusterName(cn ClusterName) (res *http.Response, err error)

SetClusterName sets cluster name.

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration)

SetTimeout changes the HTTP timeout that the Client will use. By default there is no timeout.

func (*Client) SetTransport

func (c *Client) SetTransport(transport http.RoundTripper)

SetTransport changes the Transport Layer that the Client will use.

func (*Client) SyncQueue

func (c *Client) SyncQueue(vhost, queue string) (res *http.Response, err error)

SyncQueue synchronises queue contents with the mirrors remaining in the cluster.

func (*Client) UpdatePermissionsIn

func (c *Client) UpdatePermissionsIn(vhost, username string, permissions Permissions) (res *http.Response, err error)

UpdatePermissionsIn sets permissions of a user in a virtual host.

func (*Client) UpdateTopicPermissionsIn

func (c *Client) UpdateTopicPermissionsIn(vhost, username string, TopicPermissions TopicPermissions) (res *http.Response, err error)

UpdateTopicPermissionsIn updates topic-permissions of user in virtual host.

func (*Client) Whoami

func (c *Client) Whoami() (rec *WhoamiInfo, err error)

Whoami echoes requesting user's name back.

type ClusterName

type ClusterName struct {
	Name string `json:"name"`
}

ClusterName represents a RabbitMQ cluster name (identifier).

type ConnectionInfo

type ConnectionInfo struct {
	// Connection name
	Name string `json:"name"`
	// Node the client is connected to
	Node string `json:"node"`
	// Number of open channels
	Channels int `json:"channels"`
	// Connection state
	State string `json:"state"`
	// Connection type, network (via AMQP client) or direct (via direct Erlang client)
	Type string `json:"type"`

	// Server port
	Port Port `json:"port"`
	// Client port
	PeerPort Port `json:"peer_port"`

	// Server host
	Host string `json:"host"`
	// Client host
	PeerHost string `json:"peer_host"`

	// Last connection blocking reason, if any
	LastBlockedBy string `json:"last_blocked_by"`
	// When connection was last blocked
	LastBlockedAge string `json:"last_blocked_age"`

	// True if connection uses TLS/SSL
	UsesTLS bool `json:"ssl"`
	// Client certificate subject
	PeerCertSubject string `json:"peer_cert_subject"`
	// Client certificate validity
	PeerCertValidity string `json:"peer_cert_validity"`
	// Client certificate issuer
	PeerCertIssuer string `json:"peer_cert_issuer"`

	// TLS/SSL protocol and version
	SSLProtocol string `json:"ssl_protocol"`
	// Key exchange mechanism
	SSLKeyExchange string `json:"ssl_key_exchange"`
	// SSL cipher suite used
	SSLCipher string `json:"ssl_cipher"`
	// SSL hash
	SSLHash string `json:"ssl_hash"`

	// Protocol, e.g. AMQP 0-9-1 or MQTT 3-1
	Protocol string `json:"protocol"`
	User     string `json:"user"`
	// Virtual host
	Vhost string `json:"vhost"`

	// Heartbeat timeout
	Timeout int `json:"timeout"`
	// Maximum frame size (AMQP 0-9-1)
	FrameMax int `json:"frame_max"`

	// A map of client properties (name, version, capabilities, etc)
	ClientProperties Properties `json:"client_properties"`

	// Octets received
	RecvOct uint64 `json:"recv_oct"`
	// Octets sent
	SendOct     uint64 `json:"send_oct"`
	RecvCount   uint64 `json:"recv_cnt"`
	SendCount   uint64 `json:"send_cnt"`
	SendPending uint64 `json:"send_pend"`
	// Ingress data rate
	RecvOctDetails RateDetails `json:"recv_oct_details"`
	// Egress data rate
	SendOctDetails RateDetails `json:"send_oct_details"`

	// Connection timestamp
	ConnectedAt uint64 `json:"connected_at,omitempty"`
}

ConnectionInfo provides information about connection to a RabbitMQ node.

type ConsumerInfo

type ConsumerInfo struct {
	Arguments           map[string]interface{} `json:"arguments"`
	AcknowledgementMode AcknowledgementMode    `json:"ack_required"`
	ChannelDetails      BriefChannelDetail     `json:"channel_details"`
	ConsumerTag         string                 `json:"consumer_tag"`
	Exclusive           bool                   `json:"exclusive"`
	PrefetchCount       int                    `json:"prefetch_count"`
	Queue               BriefQueueInfo         `json:"queue"`
}

ConsumerInfo represents a consumer.

type DeleteAfter

type DeleteAfter string

DeleteAfter after can hold a delete-after value which may be a string (eg. "never") or an integer

func (DeleteAfter) MarshalJSON

func (d DeleteAfter) MarshalJSON() ([]byte, error)

MarshalJSON can marshal a string or an integer

func (*DeleteAfter) UnmarshalJSON

func (d *DeleteAfter) UnmarshalJSON(b []byte) error

UnmarshalJSON can unmarshal a string or an integer

type DetailedExchangeInfo

type DetailedExchangeInfo struct {
	Name       string                 `json:"name"`
	Vhost      string                 `json:"vhost"`
	Type       string                 `json:"type"`
	Durable    bool                   `json:"durable"`
	AutoDelete bool                   `json:"auto_delete"`
	Internal   bool                   `json:"internal"`
	Arguments  map[string]interface{} `json:"arguments"`

	Incoming     []ExchangeIngressDetails `json:"incoming"`
	Outgoing     []ExchangeEgressDetails  `json:"outgoing"`
	PublishStats IngressEgressStats       `json:"message_stats"`
}

DetailedExchangeInfo represents an exchange with all of its properties and metrics.

type DetailedQueueInfo

type DetailedQueueInfo QueueInfo

DetailedQueueInfo is an alias for QueueInfo

type ErlangApp

type ErlangApp NameDescriptionVersion

ErlangApp is an Erlang application running on a node.

type ErrorResponse

type ErrorResponse struct {
	StatusCode int
	Message    string `json:"error"`
	Reason     string `json:"reason"`
}

ErrorResponse represents an error reported by an API response.

func (ErrorResponse) Error

func (rme ErrorResponse) Error() string

type ExchangeEgressDetails

type ExchangeEgressDetails struct {
	Stats MessageStats `json:"stats"`
	Queue NameAndVhost `json:"queue"`
}

ExchangeEgressDetails represents egress (outbound) message flow metrics of an exchange.

type ExchangeInfo

type ExchangeInfo struct {
	Name       string                 `json:"name"`
	Vhost      string                 `json:"vhost"`
	Type       string                 `json:"type"`
	Durable    bool                   `json:"durable"`
	AutoDelete bool                   `json:"auto_delete"`
	Internal   bool                   `json:"internal"`
	Arguments  map[string]interface{} `json:"arguments"`

	MessageStats IngressEgressStats `json:"message_stats"`
}

ExchangeInfo represents and exchange and its properties.

type ExchangeIngressDetails

type ExchangeIngressDetails struct {
	Stats          MessageStats      `json:"stats"`
	ChannelDetails PublishingChannel `json:"channel_details"`
}

ExchangeIngressDetails represents ingress (inbound) message flow metrics of an exchange.

type ExchangeSettings

type ExchangeSettings struct {
	Type       string                 `json:"type"`
	Durable    bool                   `json:"durable"`
	AutoDelete bool                   `json:"auto_delete,omitempty"`
	Arguments  map[string]interface{} `json:"arguments,omitempty"`
}

ExchangeSettings is a set of exchange properties. Use this type when declaring an exchange.

type ExchangeType

type ExchangeType NameDescriptionEnabled

ExchangeType is an exchange type available on the node.

type ExportedDefinitions added in v2.6.11

type ExportedDefinitions struct {
	RabbitVersion    string `json:"rabbit_version"`
	RabbitMQVersion  string `json:"rabbitmq_version"`
	ProductName      string `json:"product_name"`
	ProductVersion   string `json:"product_version"`
	Users            []UserInfo
	Vhosts           []VhostInfo
	Permissions      []Permissions
	TopicPermissions []TopicPermissionInfo
	Parameters       []RuntimeParameter
	GlobalParameters []GlobalRuntimeParameter `json:"global_parameters"`
	Policies         []PolicyDefinition
	Queues           []QueueInfo
	Exchanges        []ExchangeInfo
	Bindings         []BindingInfo
}

ExportedDefinitions represents definitions exported from a RabbitMQ cluster

type FeatureFlag

type FeatureFlag struct {
	Name string `json:"name"`
	// Desc is the description of the feature flag.
	Desc string `json:"desc,omitempty"`
	// DocURL is the URL to a webpage to learn more about the feature flag.
	DocURL    string    `json:"doc_url,omitempty"`
	State     State     `json:"state,omitempty"`
	Stability Stability `json:"stability,omitempty"`
	// ProvidedBy is the RabbitMQ component or plugin which provides the feature flag.
	ProvidedBy string `json:"provided_by,omitempty"`
}

Feature flags are a mechanism that controls what features are considered to be enabled or available on all cluster nodes. If a FeatureFlag is enabled so is its associated feature (or behavior). If not then all nodes in the cluster will disable the feature (behavior).

type FederationDefinition

type FederationDefinition struct {
	Uri            string `json:"uri"`
	Expires        int    `json:"expires,omitempty"`
	MessageTTL     int32  `json:"message-ttl"`
	MaxHops        int    `json:"max-hops"`
	PrefetchCount  int    `json:"prefetch-count"`
	ReconnectDelay int    `json:"reconnect-delay"`
	AckMode        string `json:"ack-mode,omitempty"`
	TrustUserId    bool   `json:"trust-user-id"`
	Exchange       string `json:"exchange"`
	Queue          string `json:"queue"`
}

FederationDefinition represents settings that will be used by federation links.

type FederationUpstream

type FederationUpstream struct {
	Name       string               `json:"name"`
	Vhost      string               `json:"vhost"`
	Component  string               `json:"component"`
	Definition FederationDefinition `json:"value"`
}

FederationUpstream represents a configured federation upstream.

type GlobalRuntimeParameter added in v2.6.11

type GlobalRuntimeParameter struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

GlobalRuntimeParameter represents a vhost-scoped parameter. Value is interface{} to support creating parameters directly from types such as FederationUpstream and ShovelInfo.

type HashingAlgorithm

type HashingAlgorithm string

HashingAlgorithm represents a hashing algorithm used by RabbitMQ's an internal authentication backend.

const (
	// HashingAlgorithmSHA256 sets password hashing algorithm to SHA-256.
	HashingAlgorithmSHA256 HashingAlgorithm = "rabbit_password_hashing_sha256"
	// HashingAlgorithmSHA512 sets password hashing algorithm to SHA-512.
	HashingAlgorithmSHA512 HashingAlgorithm = "rabbit_password_hashing_sha512"

	// HashingAlgorithmMD5 provided to support responses that include users created
	// before RabbitMQ 3.6 and other legacy scenarios. This algorithm is
	// deprecated.
	HashingAlgorithmMD5 HashingAlgorithm = "rabbit_password_hashing_md5"
)

func (HashingAlgorithm) String

func (algo HashingAlgorithm) String() string

type IngressEgressStats

type IngressEgressStats struct {
	PublishIn        int         `json:"publish_in"`
	PublishInDetails RateDetails `json:"publish_in_details"`

	PublishOut        int         `json:"publish_out"`
	PublishOutDetails RateDetails `json:"publish_out_details"`
}

IngressEgressStats represents common message flow metrics.

type Listener

type Listener struct {
	Node      string `json:"node"`
	Protocol  string `json:"protocol"`
	IpAddress string `json:"ip_address"`
	Port      Port   `json:"port"`
}

Listener represents a TCP listener on a node.

type MessageStats

type MessageStats struct {
	Publish                 int64       `json:"publish"`
	PublishDetails          RateDetails `json:"publish_details"`
	Deliver                 int64       `json:"deliver"`
	DeliverDetails          RateDetails `json:"deliver_details"`
	DeliverNoAck            int64       `json:"deliver_noack"`
	DeliverNoAckDetails     RateDetails `json:"deliver_noack_details"`
	DeliverGet              int64       `json:"deliver_get"`
	DeliverGetDetails       RateDetails `json:"deliver_get_details"`
	Redeliver               int64       `json:"redeliver"`
	RedeliverDetails        RateDetails `json:"redeliver_details"`
	Get                     int64       `json:"get"`
	GetDetails              RateDetails `json:"get_details"`
	GetNoAck                int64       `json:"get_no_ack"`
	GetNoAckDetails         RateDetails `json:"get_no_ack_details"`
	Ack                     int64       `json:"ack"`
	AckDetails              RateDetails `json:"ack_details"`
	ReturnUnroutable        int64       `json:"return_unroutable"`
	ReturnUnroutableDetails RateDetails `json:"return_unroutable_details"`
	DropUnroutable          int64       `json:"drop_unroutable"`
	DropUnroutableDetails   RateDetails `json:"drop_unroutable_details"`
}

MessageStats fields repsent a number of metrics related to published messages

type NameAndVhost

type NameAndVhost struct {
	Name  string `json:"name"`
	Vhost string `json:"vhost"`
}

NameAndVhost repesents a named entity in a virtual host.

type NameDescriptionEnabled

type NameDescriptionEnabled struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Enabled     bool   `json:"enabled"`
}

NameDescriptionEnabled represents a named entity with a description.

type NameDescriptionVersion

type NameDescriptionVersion struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Version     string `json:"version"`
}

NameDescriptionVersion represents a named, versioned entity.

type NodeInfo

type NodeInfo struct {
	Name      string `json:"name"`
	NodeType  string `json:"type"`
	IsRunning bool   `json:"running"`
	OsPid     OsPid  `json:"os_pid"`

	FdUsed        int  `json:"fd_used"`
	FdTotal       int  `json:"fd_total"`
	ProcUsed      int  `json:"proc_used"`
	ProcTotal     int  `json:"proc_total"`
	SocketsUsed   int  `json:"sockets_used"`
	SocketsTotal  int  `json:"sockets_total"`
	MemUsed       int  `json:"mem_used"`
	MemLimit      int  `json:"mem_limit"`
	MemAlarm      bool `json:"mem_alarm"`
	DiskFree      int  `json:"disk_free"`
	DiskFreeLimit int  `json:"disk_free_limit"`
	DiskFreeAlarm bool `json:"disk_free_alarm"`

	// Erlang scheduler run queue length
	RunQueueLength uint32 `json:"run_queue"`
	Processors     uint32 `json:"processors"`
	Uptime         uint64 `json:"uptime"`

	ExchangeTypes  []ExchangeType  `json:"exchange_types"`
	AuthMechanisms []AuthMechanism `json:"auth_mechanisms"`
	ErlangApps     []ErlangApp     `json:"applications"`
	Contexts       []BrokerContext `json:"contexts"`

	Partitions []string `json:"partitions"`
}

NodeInfo describes a RabbitMQ node and its basic metrics (such as resource usage).

type NodeNames

type NodeNames []string

NodeNames is a list of node names.

type ObjectTotals

type ObjectTotals struct {
	Consumers   int `json:"consumers"`
	Queues      int `json:"queues"`
	Exchanges   int `json:"exchanges"`
	Connections int `json:"connections"`
	Channels    int `json:"channels"`
}

ObjectTotals represents object (connections, queues, consumers, etc) metrics across the entire cluster.

type OsPid

type OsPid string

OsPid is an operating system process ID.

type Overview

type Overview struct {
	ManagementVersion string          `json:"management_version"`
	StatisticsLevel   string          `json:"statistics_level"`
	RabbitMQVersion   string          `json:"rabbitmq_version"`
	ErlangVersion     string          `json:"erlang_version"`
	FullErlangVersion string          `json:"erlang_full_version"`
	ExchangeTypes     []ExchangeType  `json:"exchange_types"`
	MessageStats      MessageStats    `json:"message_stats"`
	QueueTotals       QueueTotals     `json:"queue_totals"`
	ObjectTotals      ObjectTotals    `json:"object_totals"`
	Node              string          `json:"node"`
	StatisticsDBNode  string          `json:"statistics_db_node"`
	Listeners         []Listener      `json:"listeners"`
	Contexts          []BrokerContext `json:"contexts"`
}

Overview provides a point-in-time overview of cluster state and some of its key aggregated metrics.

type OwnerPidDetails

type OwnerPidDetails struct {
	Name     string `json:"name"`
	PeerPort Port   `json:"peer_port"`
	PeerHost string `json:"peer_host"`
}

OwnerPidDetails describes an exclusive queue owner (connection).

type PagedQueueInfo

type PagedQueueInfo struct {
	Page          int         `json:"page"`
	PageCount     int         `json:"page_count"`
	PageSize      int         `json:"page_size"`
	FilteredCount int         `json:"filtered_count"`
	ItemCount     int         `json:"item_count"`
	TotalCount    int         `json:"total_count"`
	Items         []QueueInfo `json:"items"`
}

PagedQueueInfo is additional context returned for paginated requests.

type PermissionInfo

type PermissionInfo struct {
	User  string `json:"user"`
	Vhost string `json:"vhost"`

	// Configuration permissions
	Configure string `json:"configure"`
	// Write permissions
	Write string `json:"write"`
	// Read permissions
	Read string `json:"read"`
}

PermissionInfo represents a user's permission in a virtual host.

type Permissions

type Permissions struct {
	Configure string `json:"configure"`
	Write     string `json:"write"`
	Read      string `json:"read"`
}

Permissions represents permissions of a user in a virtual host. Use this type to set permissions of the user.

type Policy

type Policy struct {
	// Virtual host this policy is in.
	Vhost string `json:"vhost"`
	// Regular expression pattern used to match queues and exchanges,
	// , e.g. "^ha\..+"
	Pattern string `json:"pattern"`
	// What this policy applies to: "queues", "exchanges", etc.
	ApplyTo  string `json:"apply-to"`
	Name     string `json:"name"`
	Priority int    `json:"priority"`
	// Additional arguments added to the entities (queues,
	// exchanges or both) that match a policy
	Definition PolicyDefinition `json:"definition"`
}

Policy represents a configured policy.

type PolicyDefinition

type PolicyDefinition map[string]interface{}

PolicyDefinition is a map of additional arguments added to the entities (queues, exchanges or both) that match a policy.

type Port

type Port int

Port used by RabbitMQ or clients

func (*Port) UnmarshalJSON

func (p *Port) UnmarshalJSON(b []byte) error

UnmarshalJSON deserialises

type Properties

type Properties map[string]interface{}

Properties are extra arguments as a map (on queues, bindings, etc)

type PublishingChannel

type PublishingChannel struct {
	Number         int    `json:"number"`
	Name           string `json:"name"`
	ConnectionName string `json:"connection_name"`
	PeerPort       Port   `json:"peer_port"`
	PeerHost       string `json:"peer_host"`
}

PublishingChannel represents a channel and its basic properties.

type QueueDeleteOptions

type QueueDeleteOptions struct {
	// Only delete the queue if there are no messages.
	IfEmpty bool
	// Only delete the queue if there are no consumers.
	IfUnused bool
}

Options for deleting a queue. Use it with DeleteQueue.

type QueueInfo

type QueueInfo struct {
	// Queue name
	Name string `json:"name"`
	// Virtual host this queue belongs to
	Vhost string `json:"vhost"`
	// Is this queue durable?
	Durable bool `json:"durable"`
	// Is this queue auto-delted?
	AutoDelete bool `json:"auto_delete"`
	// Extra queue arguments
	Arguments map[string]interface{} `json:"arguments"`

	// RabbitMQ node that hosts master for this queue
	Node string `json:"node"`
	// Queue status
	Status string `json:"state"`

	// Total amount of RAM used by this queue
	Memory int64 `json:"memory"`
	// How many consumers this queue has
	Consumers int `json:"consumers"`
	// Utilisation of all the consumers
	ConsumerUtilisation float64 `json:"consumer_utilisation"`
	// If there is an exclusive consumer, its consumer tag
	ExclusiveConsumerTag string `json:"exclusive_consumer_tag"`

	// Policy applied to this queue, if any
	Policy string `json:"policy"`

	// Total bytes of messages in this queues
	MessagesBytes           int64 `json:"message_bytes"`
	MessagesBytesPersistent int64 `json:"message_bytes_persistent"`
	MessagesBytesRAM        int64 `json:"message_bytes_ram"`

	// Total number of messages in this queue
	Messages           int         `json:"messages"`
	MessagesDetails    RateDetails `json:"messages_details"`
	MessagesPersistent int         `json:"messages_persistent"`
	MessagesRAM        int         `json:"messages_ram"`

	// Number of messages ready to be delivered
	MessagesReady        int         `json:"messages_ready"`
	MessagesReadyDetails RateDetails `json:"messages_ready_details"`

	// Number of messages delivered and pending acknowledgements from consumers
	MessagesUnacknowledged        int         `json:"messages_unacknowledged"`
	MessagesUnacknowledgedDetails RateDetails `json:"messages_unacknowledged_details"`

	MessageStats MessageStats `json:"message_stats"`

	OwnerPidDetails OwnerPidDetails `json:"owner_pid_details"`

	BackingQueueStatus BackingQueueStatus `json:"backing_queue_status"`

	ActiveConsumers int64 `json:"active_consumers"`
}

QueueInfo represents a queue, its properties and key metrics.

type QueueSettings

type QueueSettings struct {
	Type       string                 `json:"type"`
	Durable    bool                   `json:"durable"`
	AutoDelete bool                   `json:"auto_delete,omitempty"`
	Arguments  map[string]interface{} `json:"arguments,omitempty"`
}

QueueSettings represents queue properties. Use it to declare a queue.

type QueueTotals

type QueueTotals struct {
	Messages        int         `json:"messages"`
	MessagesDetails RateDetails `json:"messages_details"`

	MessagesReady        int         `json:"messages_ready"`
	MessagesReadyDetails RateDetails `json:"messages_ready_details"`

	MessagesUnacknowledged        int         `json:"messages_unacknowledged"`
	MessagesUnacknowledgedDetails RateDetails `json:"messages_unacknowledged_details"`
}

QueueTotals represents queue metrics across the entire cluster.

type RateDetailSample

type RateDetailSample struct {
	Sample    int64 `json:"sample"`
	Timestamp int64 `json:"timestamp"`
}

RateDetailSample single touple

type RateDetails

type RateDetails struct {
	Rate    float32            `json:"rate"`
	Samples []RateDetailSample `json:"samples"`
}

RateDetails fields represent rate of change of a numerical value

type RuntimeParameter

type RuntimeParameter struct {
	Name      string      `json:"name"`
	Vhost     string      `json:"vhost"`
	Component string      `json:"component"`
	Value     interface{} `json:"value"`
}

RuntimeParameter represents a vhost-scoped runtime parameter. Value is interface{} to support creating parameters directly from types such as FederationUpstream and ShovelInfo.

type RuntimeParameterValue

type RuntimeParameterValue map[string]interface{}

RuntimeParameterValue represents arbitrary parameter data.

type ShovelDefinition

type ShovelDefinition struct {
	AckMode                          string      `json:"ack-mode,omitempty"`
	AddForwardHeaders                bool        `json:"add-forward-headers,omitempty"`
	DeleteAfter                      DeleteAfter `json:"delete-after,omitempty"`
	DestinationAddForwardHeaders     bool        `json:"dest-add-forward-headers,omitempty"`
	DestinationAddTimestampHeader    bool        `json:"dest-add-timestamp-header,omitempty"`
	DestinationAddress               string      `json:"dest-address,omitempty"`
	DestinationApplicationProperties string      `json:"dest-application-properties,omitempty"`
	DestinationExchange              string      `json:"dest-exchange,omitempty"`
	DestinationExchangeKey           string      `json:"dest-exchange-key,omitempty"`
	DestinationProperties            string      `json:"dest-properties,omitempty"`
	DestinationProtocol              string      `json:"dest-protocol,omitempty"`
	DestinationPublishProperties     string      `json:"dest-publish-properties,omitempty"`
	DestinationQueue                 string      `json:"dest-queue,omitempty"`
	DestinationURI                   []string    `json:"dest-uri"`
	PrefetchCount                    int         `json:"prefetch-count,omitempty"`
	ReconnectDelay                   int         `json:"reconnect-delay,omitempty"`
	SourceAddress                    string      `json:"src-address,omitempty"`
	SourceDeleteAfter                string      `json:"src-delete-after,omitempty"`
	SourceExchange                   string      `json:"src-exchange,omitempty"`
	SourceExchangeKey                string      `json:"src-exchange-key,omitempty"`
	SourcePrefetchCount              int         `json:"src-prefetch-count,omitempty"`
	SourceProtocol                   string      `json:"src-protocol,omitempty"`
	SourceQueue                      string      `json:"src-queue,omitempty"`
	SourceURI                        []string    `json:"src-uri"`
}

ShovelDefinition contains the details of the shovel configuration

type ShovelDefinitionDTO

type ShovelDefinitionDTO struct {
	Definition ShovelDefinition `json:"value"`
}

ShovelDefinitionDTO provides a data transfer object

type ShovelInfo

type ShovelInfo struct {
	// Shovel name
	Name string `json:"name"`
	// Virtual host this shovel belongs to
	Vhost string `json:"vhost"`
	// Component shovels belong to
	Component string `json:"component"`
	// Details the configuration values of the shovel
	Definition ShovelDefinition `json:"value"`
}

ShovelInfo contains the configuration of a shovel

type Stability

type Stability string
const (
	StabilityStable       Stability = "stable"
	StabilityExperimental Stability = "experimental"
)

type State

type State string
const (
	StateEnabled  State = "enabled"
	StateDisabled State = "disabled"
	// StateUnsupported means that one or more nodes in the cluster do not know this feature flag (and therefore it cannot be enabled).
	StateUnsupported State = "unsupported"
)

type TopicPermissionInfo

type TopicPermissionInfo struct {
	User  string `json:"user"`
	Vhost string `json:"vhost"`

	// Configuration topic-permisions
	Exchange string `json:"exchange"`
	// Write topic-permissions
	Write string `json:"write"`
	// Read topic-permissions
	Read string `json:"read"`
}

TopicPermissionInfo represents a user's permissions on a topic.

type TopicPermissions

type TopicPermissions struct {
	Exchange string `json:"exchange"`
	Write    string `json:"write"`
	Read     string `json:"read"`
}

TopicPermissions represents a user's permissions on a topic.

type UserInfo

type UserInfo struct {
	Name             string           `json:"name"`
	PasswordHash     string           `json:"password_hash"`
	HashingAlgorithm HashingAlgorithm `json:"hashing_algorithm,omitempty"`
	// Tags control permissions. Built-in tags: administrator, management, policymaker.
	Tags UserTags `json:"tags"`
}

UserInfo represents a user record. Only relevant when internal authentication backend is used.

type UserSettings

type UserSettings struct {
	Name string `json:"name"`
	// Tags control permissions. Administrator grants full
	// permissions, management grants management UI and HTTP API
	// access, policymaker grants policy management permissions.
	Tags UserTags `json:"tags"`

	// *never* returned by RabbitMQ. Set by the client
	// to create/update a user. MK.
	Password         string           `json:"password,omitempty"`
	PasswordHash     string           `json:"password_hash,omitempty"`
	HashingAlgorithm HashingAlgorithm `json:"hashing_algorithm,omitempty"`
}

UserSettings represents properties of a user. Used to create users. Tags must be comma-separated.

type UserTags

type UserTags []string

UserTags represents tags of a user. In HTTP API responses this can be a JSON array (3.9.0+) or a comma-separated list in a string.

func (UserTags) MarshalJSON

func (d UserTags) MarshalJSON() ([]byte, error)

MarshalJSON can marshal an array of strings or a comma-separated list in a string

func (*UserTags) UnmarshalJSON

func (d *UserTags) UnmarshalJSON(b []byte) error

UnmarshalJSON can unmarshal an array of strings or a comma-separated list in a string

type VhostInfo

type VhostInfo struct {
	// Virtual host name
	Name string `json:"name"`
	// True if tracing is enabled for this virtual host
	Tracing bool `json:"tracing"`

	// Total number of messages in queues of this virtual host
	Messages        int         `json:"messages"`
	MessagesDetails RateDetails `json:"messages_details"`

	// Total number of messages ready to be delivered in queues of this virtual host
	MessagesReady        int         `json:"messages_ready"`
	MessagesReadyDetails RateDetails `json:"messages_ready_details"`

	// Total number of messages pending acknowledgement from consumers in this virtual host
	MessagesUnacknowledged        int         `json:"messages_unacknowledged"`
	MessagesUnacknowledgedDetails RateDetails `json:"messages_unacknowledged_details"`

	// Octets received
	RecvOct uint64 `json:"recv_oct"`
	// Octets sent
	SendOct        uint64      `json:"send_oct"`
	RecvCount      uint64      `json:"recv_cnt"`
	SendCount      uint64      `json:"send_cnt"`
	SendPending    uint64      `json:"send_pend"`
	RecvOctDetails RateDetails `json:"recv_oct_details"`
	SendOctDetails RateDetails `json:"send_oct_details"`

	// Cluster State
	ClusterState map[string]string `json:"cluster_state"`
}

VhostInfo represents a virtual host, its properties and key metrics.

type VhostSettings

type VhostSettings struct {
	// True if tracing should be enabled.
	Tracing bool `json:"tracing"`
}

VhostSettings are properties used to create or modify virtual hosts.

type WhoamiInfo

type WhoamiInfo struct {
	Name        string   `json:"name"`
	Tags        UserTags `json:"tags"`
	AuthBackend string   `json:"auth_backend"`
}

WhoamiInfo represents a user whose request was successfully authenticated by the "whoami" API endpoint.

Jump to

Keyboard shortcuts

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