Documentation ¶
Overview ¶
Package eventbus provides PubSub interface used for distributed cache invalidation, as well as NopPubSub and RedisPubSub implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NopPubSub ¶
type NopPubSub struct{}
NopPubSub implements default do-nothing pub-sub (event bus)
type PubSub ¶
type PubSub interface { Publish(fromID, key string) error Subscribe(fn func(fromID, key string)) error }
PubSub interface is used for distributed cache invalidation. Publish is called on each entry invalidation, Subscribe is used for subscription for these events.
type RedisPubSub ¶
type RedisPubSub struct {
// contains filtered or unexported fields
}
RedisPubSub provides Redis implementation for PubSub interface
func NewRedisPubSub ¶
func NewRedisPubSub(addr, channel string) (*RedisPubSub, error)
NewRedisPubSub creates new RedisPubSub with given parameters. Returns an error in case of problems with creating PubSub client for specified channel.
func (*RedisPubSub) Close ¶
func (m *RedisPubSub) Close() error
Close cleans up running goroutines and closes Redis clients
func (*RedisPubSub) Publish ¶
func (m *RedisPubSub) Publish(fromID, key string) error
Publish publishes provided message to channel provided on new RedisPubSub instance creation
func (*RedisPubSub) Subscribe ¶
func (m *RedisPubSub) Subscribe(fn func(fromID, key string)) error
Subscribe calls provided function on subscription channel provided on new RedisPubSub instance creation. Should not be called more than once. Spawns a goroutine and does not return an error.