cpubsub

package
v0.0.0-...-5538d7f Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalFx = fx.Provide(
	NewLocalPubSub,
)
View Source
var RedisFx = fx.Provide(
	NewRedisPubSub,
)

Functions

This section is empty.

Types

type Handler

type Handler func(payload []byte)

type LocalPubSub

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

LocalPubSub is an implementation of PubSub that only allows publishing of payloads to 'local' subscribers i.e. subscribers on the same instance as the publisher.

func NewLocalPubSub

func NewLocalPubSub() *LocalPubSub

func (*LocalPubSub) Publish

func (l *LocalPubSub) Publish(topic string, payload []byte) error

func (*LocalPubSub) Subscribe

func (l *LocalPubSub) Subscribe(topic string, handler *Handler) error

type PubSub

type PubSub interface {
	Subscribe(topic string, handler *Handler) error
	Publish(topic string, payload []byte) error
}

func NewRedisPubSub

func NewRedisPubSub(config RedisConfig, lc fx.Lifecycle, logger clogger.Logger) PubSub

type RedisConfig

type RedisConfig struct {
	Addr string
}

type RedisPubSub

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

func (*RedisPubSub) Publish

func (r *RedisPubSub) Publish(topic string, payload []byte) error

func (*RedisPubSub) Subscribe

func (r *RedisPubSub) Subscribe(topic string, handler *Handler) error

Jump to

Keyboard shortcuts

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