gebus_amqp

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: MIT Imports: 3 Imported by: 0

README

gebus-amqp

Implementation of gebus interfaces for AMQP. It allows using gebus with software like rabbitmq.

Testing note

Simplest way of testing is using devcontainer of vscode. It runs rabbitmq, so that go test command simply works.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACKingAdapter

type ACKingAdapter struct {
	// Deserializer used to deserialize events back to golang struct.
	Deserializer Deserializer

	Channel *amqp.Channel
	// Name of queue to receive from
	Queue string
	// Name of consumer
	Consumer string
	// contains filtered or unexported fields
}

AckingAdapter fits gebus' ACKingAdapter interface. It's able to receive jobs as a messages from AMQP queue.

Note: closing this adapter closes entire AMQP channel.

func (*ACKingAdapter) ACKPositive

func (aa *ACKingAdapter) ACKPositive() (err error)

func (*ACKingAdapter) Close

func (aa *ACKingAdapter) Close() (err error)

func (*ACKingAdapter) GetCurrentEvent

func (aa *ACKingAdapter) GetCurrentEvent() interface{}

func (*ACKingAdapter) Initialize

func (aa *ACKingAdapter) Initialize() (err error)

Initializes adapter making it able ot receive messages.

func (*ACKingAdapter) NextEvent

func (aa *ACKingAdapter) NextEvent(ctx context.Context) (event interface{}, err error)

Requests next event from server adapter. Should not block longer than until context times out.

type Client

type Client struct {
	Serializer Serializer

	// AMQP channel to use.
	Channel *amqp.Channel

	// ExchangeFunc provides exchange to use for specified event.
	// It's mandatory.
	ExchangeFunc func(ctx context.Context, event interface{}) (exchange string, err error)

	// KeyFunc provides key to use for specified event.
	// It's not mandatory. Default key is blank string.
	// In some exchanges key is ignored, so this is fine.
	KeyFunc func(ctx context.Context, event interface{}) (key string, err error)
}

Client is event handler, which sends messages to specified AMQP exchange.

func (*Client) HandleEvent

func (cl *Client) HandleEvent(ctx context.Context, event interface{}) (err error)

type Delivery

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

func (Delivery) GetBody

func (d Delivery) GetBody() []byte

func (Delivery) GetContentType

func (d Delivery) GetContentType() string

func (Delivery) GetHeaders

func (d Delivery) GetHeaders() map[string]string

type Deserializer

type Deserializer interface {
	DeserializeEvent(ctx context.Context, delivery Delivery) (event interface{}, err error)
}

type Publishing

type Publishing struct {
	ContentType string
	Headers     map[string]string
	Body        []byte
}

type Serializer

type Serializer interface {
	SerializeEvent(ctx context.Context, event interface{}) (pub Publishing, err error)
}

Jump to

Keyboard shortcuts

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