Documentation
¶
Index ¶
- type Config
- type StackExchange
- func (exc *StackExchange) Ask(ctx context.Context, msg neffos.Message, token string) (response neffos.Message, err error)
- func (exc *StackExchange) NotifyAsk(msg neffos.Message, token string) error
- func (exc *StackExchange) OnConnect(c *neffos.Conn) error
- func (exc *StackExchange) OnDisconnect(c *neffos.Conn)
- func (exc *StackExchange) Publish(msgs []neffos.Message) bool
- func (exc *StackExchange) Subscribe(c *neffos.Conn, namespace string)
- func (exc *StackExchange) Unsubscribe(c *neffos.Conn, namespace string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 "127.0.0.1:6379". 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.