mq

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mq

Package mq

Package mq

Index

Constants

View Source
const DefaultMessageUUIDHeaderKey = "_message_uuid"

Variables

This section is empty.

Functions

func NewConsumer

func NewConsumer(mq *Client, opts ...func(*Option)) message.Subscriber

NewConsumer create message.Subscriber

func NewProducer

func NewProducer(mq *Client, opts ...func(*Option)) message.Publisher

NewProducer return message.Publisher

Types

type Client

type Client struct {
	*amqp.Connection
	// contains filtered or unexported fields
}

func New

func New(opts ...func(*Option)) (*Client, error)

New create a mq client

func (*Client) IsConnected

func (r *Client) IsConnected() bool

type Consumer

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

func (*Consumer) Close

func (c *Consumer) Close() error

func (*Consumer) Subscribe

func (c *Consumer) Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error)

nolint:gocognit

type DefaultMarshal

type DefaultMarshal struct {
	PostprocessPublishing     func(amqp.Publishing) amqp.Publishing
	NotPersistentDeliveryMode bool
	MessageUUIDHeaderKey      string
}

func (DefaultMarshal) Marshal

func (d DefaultMarshal) Marshal(msg *message.Message) (amqp.Publishing, error)

func (DefaultMarshal) Unmarshal

func (d DefaultMarshal) Unmarshal(amqpMsg *amqp.Delivery) (*message.Message, error)

type MarshalAPI

type MarshalAPI interface {
	Marshal(msg *message.Message) (amqp.Publishing, error)
	Unmarshal(amqpMsg *amqp.Delivery) (*message.Message, error)
}

type NoopPublisher

type NoopPublisher struct {
}

func (NoopPublisher) Close

func (NoopPublisher) Close() error

func (NoopPublisher) Publish

func (NoopPublisher) Publish(string, ...*message.Message) error

type Option

type Option struct {
	Config     *amqp.Config
	URI        string
	Marshal    MarshalAPI
	QueueName  func(topic string) string
	Exchange   string
	RoutingKey string
}

type Producer

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

func (*Producer) Close

func (p *Producer) Close() error

func (*Producer) Publish

func (p *Producer) Publish(topic string, messages ...*message.Message) (err error)

func (*Producer) PublishMessage

func (p *Producer) PublishMessage(channel *amqp.Channel, msg *message.Message) error

Jump to

Keyboard shortcuts

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