pubsub

package
v0.11.6 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPubsubType = errors.New("invalid pubsub type")

ErrInvalidPubsubType is error for invalid pubsub type.

Functions

This section is empty.

Types

type Channel

type Channel interface {
	// Read and process incoming message. Param `data` should
	// be a pointer just like when using json.Unmarshal.
	Read(data interface{}) (<-chan interface{}, <-chan error)
	// Close subscription.
	Close() error
}

Channel is channel interface.

See usage example in example folder.

type PubSub

type PubSub interface {
	// Publish message to specific topic/channel.
	// Data will be encoded first before publishing.
	Publish(topic string, data interface{}) error
	// Subscribe to specific topic/channel.
	Subscribe(topic string) (interface{}, error)
	// Close pubsub client connection.
	Close() error
}

PubSub is pubsub interface.

For subscribe function, you have to convert the return type to Channel.

See usage example in example folder.

func New

func New(pubsubType PubsubType, address string, password string) (PubSub, error)

New to create new pubsub client depends on the type.

type PubsubType

type PubsubType int8

PubsubType is type for pubsub.

const (
	Redis PubsubType = iota + 1
	RabbitMQ
	NSQ
)

Available types for pubsub.

Directories

Path Synopsis
Package nsq is a wrapper of the original "github.com/nsqio/go-nsq" library.
Package nsq is a wrapper of the original "github.com/nsqio/go-nsq" library.
Package rabbitmq is a wrapper of the original "github.com/streadway/amqp" library.
Package rabbitmq is a wrapper of the original "github.com/streadway/amqp" library.
Package redis is a wrapper of the original "github.com/go-redis/redis/v8" library.
Package redis is a wrapper of the original "github.com/go-redis/redis/v8" library.

Jump to

Keyboard shortcuts

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