mq

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver Driver)

Register makes a mq driver available by the provided name

Types

type Claim

type Claim interface {
	// Err chan used to receive error
	Err() <-chan error
	// Message chan used to receive message content
	Message() <-chan []byte
}

Claim used to receive requests from mq.

type Conn

type Conn interface {
	// Close closes the conn
	Close() error
	// Ping checks the connection to topic
	Ping(topic string) error
	// Subscribe subscribes topic with consumer
	Subscribe(topic string, consumer Consumer) error
	// Publish publishs message content to topic.
	// content allowed to be modified after Publish called.
	Publish(topic string, content []byte) error
}

Conn is the top-level mq connection

func Open

func Open(name, source string, discovery discovery.Discovery) (Conn, error)

Open opens a mq connection specified by its driver name and a driver-specific source.

type Consumer

type Consumer interface {
	// Setup would be called before consumption loop
	Setup() error
	// Cleanup would be called after consumption loop
	Cleanup() error
	// Consume runs the consumption loop blocking
	Consume(topic string, claim Claim)
}

Consumer used to consume received messages from mq.

type Driver

type Driver interface {
	// Open returns a Conn instance by a driver-specific source name
	Open(source string, discovery discovery.Discovery) (Conn, error)
}

Driver is the interface that must be implemented by a mq driver

type FuncConsumer

type FuncConsumer func(topic string, msg []byte, err error)

FuncConsumer implements Consumer interface

func (FuncConsumer) Cleanup

func (fc FuncConsumer) Cleanup() error

Cleanup implements Consumer Cleanup method

func (FuncConsumer) Consume

func (fc FuncConsumer) Consume(topic string, claim Claim)

Consume implements Consumer Consume method

func (FuncConsumer) Setup

func (fc FuncConsumer) Setup() error

Setup implements Consumer Setup method

Jump to

Keyboard shortcuts

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