amqp

package
v0.0.0-...-45a9bcf Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package amqp provides a simple wrapper around 3rd party amqp client.

Index

Constants

View Source
const (
	// User is the user to use for authentication
	User = "guest"
	// Pass is the password to use for authentication
	Pass = "guest"
)

Variables

This section is empty.

Functions

func RunServer

func RunServer(t testing.TB, serverAddr, serverPort string, enableTLS bool) error

RunServer runs an AMQP server in a docker container.

Types

type Client

type Client struct {
	PublishConn    *amqp.Connection
	PublishChannel *amqp.Channel
	ConsumeConn    *amqp.Connection
	ConsumeChannel *amqp.Channel
	// contains filtered or unexported fields
}

Client is a wrapper around the amqp client

func NewClient

func NewClient(opts Options) (*Client, error)

NewClient creates a new amqp client

func (*Client) Consume

func (c *Client) Consume(queue string, numberOfMessages int) ([]string, error)

Consume reads a message from the queue

func (*Client) DeclareQueue

func (c *Client) DeclareQueue(name string, ch *amqp.Channel) error

DeclareQueue creates a queue with the given name

func (*Client) DeleteQueues

func (c *Client) DeleteQueues() error

DeleteQueues deletes all queues from the server

func (*Client) Publish

func (c *Client) Publish(queue, body string) error

Publish sends a message to the queue

func (*Client) Terminate

func (c *Client) Terminate()

Terminate closes all connections and channels

type Options

type Options struct {
	ServerAddress string
	Username      string
	Password      string
	Dialer        *net.Dialer

	// WithTLS indicates whether the connection should be made using TLS
	WithTLS bool
}

Options is a struct to hold the options for the amqp client

type Queue

type Queue struct {
	Name string
}

Queue represents an amqp queue

Jump to

Keyboard shortcuts

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