Documentation ¶
Index ¶
- Variables
- func ReplyServer(msg protos.ReplyMessage) error
- type Client
- type Config
- type StackExchange
- func (exc *StackExchange) Ask(ctx context.Context, msg wolfsocket.Message, token string) (response wolfsocket.Message, err error)
- func (exc *StackExchange) AskServer(ctx context.Context, channel string, msg protos.ServerMessage) (response *protos.ReplyMessage, err error)
- func (exc *StackExchange) Close()
- func (exc *StackExchange) NotifyAsk(msg wolfsocket.Message, token string) error
- func (exc *StackExchange) OnConnect(c *wolfsocket.Conn) error
- func (exc *StackExchange) OnDisconnect(c *wolfsocket.Conn)
- func (exc *StackExchange) Publish(channel string, msgs []protos.ServerMessage) error
- func (exc *StackExchange) Reply(err error, token string) error
- func (exc *StackExchange) Subscribe(c *wolfsocket.Conn, channel string)
- func (exc *StackExchange) Unsubscribe(c *wolfsocket.Conn, channel string)
- type StackExchangeCfgs
Constants ¶
This section is empty.
Variables ¶
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 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 }