hedwig

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 8 Imported by: 0

README

Note:

Since the release of cloudevents, there is no need to maintain hedwig anymore. Please use the Go SDK instead of using hedwig.

Hedwig Go

Golang emitter and consumer for Hedwig

About Hedwig

Hedwig is an attempt to standardize messaging and events between micro-services.

It uses RabbitMQ as the transport and simplifies the API down significantly.

Documentation

Index

Constants

View Source
const (
	PublishChannel   = "publish"
	SubscribeChannel = "subscribe"
)
View Source
const (
	// For exchanges which use RMQ delay plugin, following type should be used as ExchangeType
	ExchangeTypeDelayed = "x-delayed-message"
	// Delayed Type Exchanges also need an extra arg with following key with the value set to actual ExchangeType
	// like `direct`, `topic` etc
	DelayedExchangeArgKey = "x-delayed-type"
	// Following header should be used when you are publishing to an Delay exchange. The header value will be
	// delay in milliseconds
	DelayHeader = "x-delay"
)

Variables

View Source
var (
	ErrNilHedwig          = errors.New("hedwig is nil, use `New` to create an instance")
	ErrAlreadyInitialized = errors.New("already initialized, disconnect before attempting again")
	ErrNoBindings         = errors.New("no bindings provided, need at least one")
	ErrNoConsumerSetting  = errors.New("consumer setting is nil")
)

Functions

This section is empty.

Types

type Callback

type Callback func(<-chan amqp.Delivery, *sync.WaitGroup)

type ConsumerSetting

type ConsumerSetting struct {
	Queues map[string]*QueueSetting
	// contains filtered or unexported fields
}

type Hedwig

type Hedwig struct {
	sync.Mutex

	Settings *Settings
	Error    error
	// contains filtered or unexported fields
}

func New

func New(settings *Settings) *Hedwig

func (*Hedwig) AddQueue

func (h *Hedwig) AddQueue(qSetting *QueueSetting, qName string) error

func (*Hedwig) Consume

func (h *Hedwig) Consume() error

func (*Hedwig) Disconnect

func (h *Hedwig) Disconnect() error

func (*Hedwig) Publish

func (h *Hedwig) Publish(key string, body []byte) (err error)

func (*Hedwig) PublishWithDelay

func (h *Hedwig) PublishWithDelay(key string, body []byte, delay time.Duration) (err error)

func (*Hedwig) PublishWithHeaders

func (h *Hedwig) PublishWithHeaders(key string, body []byte, headers map[string]interface{}) (err error)

type QueueSetting

type QueueSetting struct {
	Bindings   []string
	Callback   Callback
	Durable    bool
	AutoDelete bool
	Exclusive  bool
	NoAck      bool
}

func DefaultQueueSetting

func DefaultQueueSetting(callback Callback, bindings ...string) *QueueSetting

type Settings

type Settings struct {
	Exchange          string
	ExchangeType      string
	ExchangeArgs      amqp.Table
	HeartBeatInterval time.Duration
	SocketTimeout     time.Duration
	Host              string
	Port              int
	Vhost             string
	Username          string
	Password          string
	Consumer          *ConsumerSetting
}

func DefaultSettings

func DefaultSettings() *Settings

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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