Version: v0.0.21 Latest Latest

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

Go to latest
Published: Jan 24, 2023 License: MIT Imports: 5 Imported by: 7




This section is empty.


This section is empty.


This section is empty.


type Config

type Config struct {
	// Network to use.
	// Defaults to "tcp".
	Network string
	// Addr of a single redis server instance.
	// See "Clusters" field for clusters support.
	// Defaults to "".
	Addr string
	// Clusters a list of network addresses for clusters.
	// If not empty "Addr" is ignored.
	Clusters []string

	Password    string
	DialTimeout time.Duration

	// MaxActive defines the size connection pool.
	// Defaults to 10.
	MaxActive int

Config is used on the `StackExchange` package-level function. Can be used to customize the redis client dialer.

type StackExchange

type StackExchange struct {
	// contains filtered or unexported fields

StackExchange is a `neffos.StackExchange` for redis.

func NewStackExchange

func NewStackExchange(cfg Config, channel string) (*StackExchange, error)

NewStackExchange returns a new redis StackExchange. The "channel" input argument is the channel prefix for publish and subscribe.

func (*StackExchange) Ask added in v0.0.7

func (exc *StackExchange) Ask(ctx context.Context, msg neffos.Message, token string) (response neffos.Message, err error)

Ask implements the server Ask feature for redis. It blocks until response.

func (*StackExchange) NotifyAsk added in v0.0.7

func (exc *StackExchange) NotifyAsk(msg neffos.Message, token string) error

NotifyAsk notifies and unblocks a "msg" subscriber, called on a server connection's read when expects a result.

func (*StackExchange) OnConnect

func (exc *StackExchange) OnConnect(c *neffos.Conn) error

OnConnect prepares the connection redis subscriber and subscribes to itself for direct neffos messages. It's called automatically after the neffos server's OnConnect (if any) on incoming client connections.

func (*StackExchange) OnDisconnect

func (exc *StackExchange) OnDisconnect(c *neffos.Conn)

OnDisconnect terminates the connection's subscriber that created on the `OnConnect` method. It unsubscribes to all opened channels and closes the internal read messages channel. It's called automatically when a connection goes offline, manually by server or client or by network failure.

func (*StackExchange) Publish

func (exc *StackExchange) Publish(msgs []neffos.Message) bool

Publish publishes messages through redis. It's called automatically on neffos broadcasting.

func (*StackExchange) Subscribe

func (exc *StackExchange) Subscribe(c *neffos.Conn, namespace string)

Subscribe subscribes to a specific namespace, it's called automatically on neffos namespace connected.

func (*StackExchange) Unsubscribe

func (exc *StackExchange) Unsubscribe(c *neffos.Conn, namespace string)

Unsubscribe unsubscribes from a specific namespace, it's called automatically on neffos namespace disconnect.

Jump to

Keyboard shortcuts

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