rabbitmq

package
v1.0.35 Latest Latest
Warning

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

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

Documentation

Overview

Package rabbitmq is an AMQP 0.9.1 client with RabbitMQ extensions in Go.

Example
package main

import (
	"github.com/boxgo/box/pkg/client/rabbitmq"
	"github.com/boxgo/box/pkg/logger"
)

func main() {
	ch, err := rabbitmq.StdConfig("default").Build().Channel()
	if err != nil {
		logger.Panic(err)
	}

	q, err := ch.QueueDeclare("queue-name", true, true, false, false, nil)
	if err != nil {
		logger.Panic(err, q)
	}

	err = ch.Publish("", "queue-name", false, false, rabbitmq.Publishing{
		DeliveryMode: rabbitmq.Persistent,
		ContentType:  "text/plain",
		Body:         []byte("hello world"),
	})
	if err != nil {
		logger.Panic(err)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	ContentTooLarge    = amqp.ContentTooLarge
	NoRoute            = amqp.NoRoute
	NoConsumers        = amqp.NoConsumers
	ConnectionForced   = amqp.ConnectionForced
	InvalidPath        = amqp.InvalidPath
	AccessRefused      = amqp.AccessRefused
	NotFound           = amqp.NotFound
	ResourceLocked     = amqp.ResourceLocked
	PreconditionFailed = amqp.PreconditionFailed
	FrameError         = amqp.FrameError
	SyntaxError        = amqp.SyntaxError
	CommandInvalid     = amqp.CommandInvalid
	ChannelError       = amqp.ChannelError
	UnexpectedFrame    = amqp.UnexpectedFrame
	ResourceError      = amqp.ResourceError
	NotAllowed         = amqp.NotAllowed
	NotImplemented     = amqp.NotImplemented
	InternalError      = amqp.InternalError
)
View Source
const (
	ExchangeDirect  = amqp.ExchangeDirect
	ExchangeFanout  = amqp.ExchangeFanout
	ExchangeTopic   = amqp.ExchangeTopic
	ExchangeHeaders = amqp.ExchangeHeaders
)
View Source
const (
	Transient  = amqp.Transient
	Persistent = amqp.Persistent
)

Variables

View Source
var (
	// ErrClosed is returned when the channel or connection is not open
	ErrClosed = amqp.ErrClosed

	// ErrChannelMax is returned when Connection.Channel has been called enough
	// times that all channel IDs have been exhausted in the client or the
	// server.
	ErrChannelMax = amqp.ErrChannelMax

	// ErrSASL is returned from Dial when the authentication mechanism could not
	// be negoated.
	ErrSASL = amqp.ErrSASL

	// ErrCredentials is returned when the authenticated client is not authorized
	// to any vhost.
	ErrCredentials = amqp.ErrCredentials

	// ErrVhost is returned when the authenticated user is not permitted to
	// access the requested Vhost.
	ErrVhost = amqp.ErrVhost

	// ErrSyntax is hard protocol error, indicating an unsupported protocol,
	// implementation or encoding.
	ErrSyntax = amqp.ErrSyntax

	// ErrFrame is returned when the protocol frame cannot be read from the
	// server, indicating an unsupported protocol or unsupported frame type.
	ErrFrame = amqp.ErrFrame

	// ErrCommandInvalid is returned when the server sends an unexpected response
	// to this requested message type. This indicates a bug in this client.
	ErrCommandInvalid = amqp.ErrCommandInvalid

	// ErrUnexpectedFrame is returned when something other than a method or
	// heartbeat frame is delivered to the Connection, indicating a bug in the
	// client.
	ErrUnexpectedFrame = amqp.ErrUnexpectedFrame

	// ErrFieldType is returned when writing a message containing a Go type unsupported by AMQP.
	ErrFieldType = amqp.ErrFieldType
)

Functions

This section is empty.

Types

type Channel

type Channel = amqp.Channel

type Config

type Config struct {
	URI        string        `config:"uri" desc:"Connection uri"`
	Vhost      string        `` /* 161-byte string literal not displayed */
	ChannelMax int           `config:"channelMax" desc:"0 max channels means 2^16 - 1"`
	FrameSize  int           `config:"frameSize" desc:"0 max bytes means unlimited"`
	Heartbeat  time.Duration `config:"heartbeat" desc:"less than 1s uses the server's interval"`
	// contains filtered or unexported fields
}

Config 配置

func DefaultConfig

func DefaultConfig(key string) *Config

DefaultConfig 默认配置

func StdConfig

func StdConfig(key string, optionFunc ...OptionFunc) *Config

StdConfig 标准配置

func (*Config) Build

func (c *Config) Build() *RabbitMQ

Build 构建实例

func (*Config) Path

func (c *Config) Path() string

Path 实例配置目录

type Delivery

type Delivery = amqp.Delivery

type OptionFunc

type OptionFunc func(*Config)

OptionFunc 选项信息

type Publishing

type Publishing = amqp.Publishing

type RabbitMQ

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

func (RabbitMQ) Channel

func (mq RabbitMQ) Channel() (*Channel, error)

func (*RabbitMQ) Serve

func (mq *RabbitMQ) Serve(ctx context.Context) error

func (*RabbitMQ) Shutdown

func (mq *RabbitMQ) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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