mq

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MIT Imports: 5 Imported by: 0

README

mq

message queue

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTopic         = errors.New("invalid topic")
	ErrInvalidChannel       = errors.New("invalid channel")
	ErrMessageConsumerPanic = errors.New("message consumer panic")
)

Functions

This section is empty.

Types

type MessageQueue

type MessageQueue interface {
	Publish(ctx context.Context, topic string, body []byte) error
	Consume(ctx context.Context, topic, channel string, handler func(ctx context.Context, body []byte) error) error
	Close() error
}

type NSQ

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

func NewNSQ

func NewNSQ(ctx context.Context, config *NSQConfig) (*NSQ, error)

func (NSQ) Close

func (s NSQ) Close() error

func (NSQ) Consume

func (s NSQ) Consume(ctx context.Context, topic, channel string, handler func(ctx context.Context, body []byte) error) error

func (NSQ) Output

func (s NSQ) Output(calldepth int, message string) error

func (NSQ) Publish

func (s NSQ) Publish(ctx context.Context, topic string, body []byte) error

type NSQConfig

type NSQConfig struct {
	NsqdAddress         string
	ConnectToLookupd    bool
	NsqLookupdAddresses []string
	TopicPrefix         string
	*nsq.Config
}

type RabbitMQ

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

func NewRabbitMQ

func NewRabbitMQ(ctx context.Context, config *RabbitMQConfig) (*RabbitMQ, error)

func (RabbitMQ) Close

func (s RabbitMQ) Close() error

func (*RabbitMQ) Consume

func (s *RabbitMQ) Consume(ctx context.Context, routeKey, channel string, handler func(ctx context.Context, body []byte) error) error

func (RabbitMQ) Publish

func (s RabbitMQ) Publish(ctx context.Context, routeKey string, body []byte) error

type RabbitMQConfig

type RabbitMQConfig struct {
	URL          string `json:"url"`
	Exchange     string `json:"exchange"`
	ExchangeType string `json:"exchange_type"`
}

Jump to

Keyboard shortcuts

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