rabbitmq

package
v0.9.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package rabbitmq implements the "rabbitmq" protocol.Protocol driver, for load testing a RabbitMQ 3.12 or later broker (and other brokers that speak AMQP 0-9-1). It uses a pure Go client.

A connection holds many light channels, and every call uses exactly one channel. It does not take a second channel while it holds one, so a slow call cannot deadlock the rest. Publish reuses a healthy confirm-mode channel. Consume, roundtrip and admin open a fresh channel and close it, because they leave consumer state behind.

The client library's methods wait for the broker with no deadline of their own. Each call starts a watchdog that closes the channel when the budget ends, and closes the connection if that close does not finish. Run waits for that watchdog before it returns. The next call on the shared connection would otherwise meet a close that is still in progress.

Publishing is allowed without a flag, the same as the other message brokers. Consuming with ack=ack, and the admin actions that change the broker, are not. A RabbitMQ user with limited permissions is the real lock.

Index

Constants

This section is empty.

Variables

View Source
var Options = append([]string{
	"mode", "exchange", "routing_key", "queue", "bind_key", "count",
	"confirm", "mandatory", "persistent", "content_type", "priority",
	"expiration", "headers", "ack", "prefetch", "expect", "action",
	"durable", "auto_delete", "queue_type", "exchange_type",
	"username", "password_env", "vhost", "tls", "connection", "channels",
	"heartbeat", "connection_name", "allow_writes", "allow_admin",
}, tlsconf.Keys...)

Options are the -opt keys this driver accepts. The command's protocol table uses the same list, so the two cannot differ.

Functions

This section is empty.

Types

type Driver

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

Driver is a RabbitMQ protocol.Protocol.

func New

func New(target protocol.Target, timeout time.Duration) (*Driver, error)

New builds a driver for one target. It does not connect: the first call does.

func NewConn

func NewConn(target protocol.Target, timeout time.Duration, password *string) (*Driver, error)

NewConn is New for a scenario script. It makes only the connection: the broker, the login and the connection options. It needs no mode. The job of each call is then set with Call. password is the password, which the script already holds, so password_env is not used with it.

func (*Driver) Call

func (d *Driver) Call(opts map[string]string, body []byte, timeout time.Duration) (*Driver, error)

Call returns a Driver for one call of a script: the same connection as d, with the job that opts and body describe. Closing it does nothing. Closing d closes the connection.

func (*Driver) Close

func (d *Driver) Close() error

Close implements protocol.Protocol. A Call driver shares the connection and closes nothing.

func (*Driver) Do

func (d *Driver) Do(parent context.Context) (protocol.Result, error)

Do implements protocol.Protocol.

func (*Driver) Name

func (d *Driver) Name() string

Name implements protocol.Protocol.

func (*Driver) Run

func (d *Driver) Run(parent context.Context) (protocol.Result, Reply)

Run runs one call and returns the reply a scenario script reads.

type Message

type Message struct {
	Exchange    string
	RoutingKey  string
	Body        string
	MessageID   string
	Redelivered bool
}

Message is one message a consume or roundtrip read.

type Reply

type Reply struct {
	Messages []Message
	Text     string
}

Reply is what a call read, besides the result. Text is the admin answer.

Directories

Path Synopsis
Package rabbitmqtest is a small AMQP 0-9-1 broker for tests.
Package rabbitmqtest is a small AMQP 0-9-1 broker for tests.

Jump to

Keyboard shortcuts

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