redis

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChannelEmpty = errors.New("We do not accept messages with empty channel")

	// InvalidPrefix is returned when a message with a channel prefix
	// that does not match the expected prefix is received during subscription.
	// The message is not executed to prevent unauthorized access or incorrect behavior.
	InvalidPrefix = errors.New("message received with invalid prefix")
)

Functions

func ReplyServer added in v0.1.14

func ReplyServer(msg protos.ReplyMessage) error

reply ask server

Types

type Client added in v0.1.14

type Client = redis.UniversalClient

type Config

type Config = redis.UniversalOptions

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 `wolfsocket.StackExchange` for redis.

func NewStackExchange

func NewStackExchange(cfg StackExchangeCfgs) (*StackExchange, error)

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

func (*StackExchange) Ask

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

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

func (*StackExchange) AskServer added in v0.1.14

func (exc *StackExchange) AskServer(ctx context.Context, channel string, msg protos.ServerMessage) (response *protos.ReplyMessage, err error)

func (*StackExchange) Close added in v0.1.14

func (exc *StackExchange) Close()

func (*StackExchange) NotifyAsk

func (exc *StackExchange) NotifyAsk(msg wolfsocket.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 *wolfsocket.Conn) error

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

func (*StackExchange) OnDisconnect

func (exc *StackExchange) OnDisconnect(c *wolfsocket.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(channel string, msgs []protos.ServerMessage) error

func (*StackExchange) Reply added in v0.1.14

func (exc *StackExchange) Reply(err error, token string) error

func (*StackExchange) Subscribe

func (exc *StackExchange) Subscribe(c *wolfsocket.Conn, channel string)

Subscribe subscribes to a specific channel,

func (*StackExchange) Unsubscribe

func (exc *StackExchange) Unsubscribe(c *wolfsocket.Conn, channel string)

Unsubscribe unsubscribes from a specific channel,

type StackExchangeCfgs added in v0.1.14

type StackExchangeCfgs struct {
	RedisConfig Config
	Channel     string
	wolfsocket.Namespaces
	*wolfsocket.Server
}

Jump to

Keyboard shortcuts

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