pubsub

package
v0.0.0-...-c39517e Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Publish(ctx context.Context, topic string, value []byte) error
	Subscribe(ctx context.Context, topic string, f func([]byte)) error
	Close()
}

Client specifies the interface for pubsub actions

func NewNATS

func NewNATS(url string, options ...nats.Option) Client

NewNATS returns a new nats pubsub Client

func NewRedis

func NewRedis(prefix string, opt *redis.Options) Client

NewRedis is a helper function used to create a new RedisPubSub

type NATS

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

NATS implements the pubsub Client interface

func (*NATS) Close

func (n *NATS) Close()

Close drains the NATS client

func (*NATS) Publish

func (n *NATS) Publish(_ context.Context, topic string, value []byte) error

Publish submits a message to NATS to be published on a given topic

func (*NATS) Subscribe

func (n *NATS) Subscribe(ctx context.Context, topic string, f func([]byte)) error

Subscribe reads messages from NATS on a given topic

type RedisPubSub

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

RedisPubSub is a redis implementation of the PubSub interface

func (*RedisPubSub) Close

func (r *RedisPubSub) Close()

Close stops he redis client

func (*RedisPubSub) Publish

func (r *RedisPubSub) Publish(ctx context.Context, topic string, value []byte) error

Publish send a message out to subscribers of a given subject

func (*RedisPubSub) Subscribe

func (r *RedisPubSub) Subscribe(ctx context.Context, topic string, f func([]byte)) error

Subscribe starts listening for messages on a channel, call the done function when you're finished listening.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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