Documentation ¶
Index ¶
- type Configuration
- type ConnHandler
- type PubSubConfiguration
- type RedigoService
- func (service *RedigoService) ApplyConfiguration(configuration interface{}) error
- func (service *RedigoService) GetConn() (redis.Conn, error)
- func (service *RedigoService) LoadConfiguration() (interface{}, error)
- func (service *RedigoService) Publish(ctx context.Context, channel string, data interface{}) error
- func (service *RedigoService) Restart() error
- func (service *RedigoService) RunWithConn(handler ConnHandler) error
- func (service *RedigoService) Start() error
- func (service *RedigoService) Stop() error
- func (service *RedigoService) Subscribe(ctx context.Context, subscribed SubscribedHandler, ...) error
- type SubscribedHandler
- type SubscriptionHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { Address string `yaml:"address"` MaxIdle int `yaml:"max_idle"` IdleTimeout time.Duration `yaml:"idle_timeout"` PubSub PubSubConfiguration `yaml:"pubsub"` }
Configuration is the configuration for the `RedigoService`.
type ConnHandler ¶
type ConnHandler func(conn redis.ConnWithTimeout) error
ConnHandler handler redis connection with timeout
type PubSubConfiguration ¶
type PubSubConfiguration struct { ReadTimeout time.Duration `yaml:"read_timeout"` WriteTimeout time.Duration `yaml:"write_timeout"` HealthCheckInterval time.Duration `yaml:"health_check_interval"` }
PubSubConfiguration is the configuration for PubSub connections and subscriptions.
type RedigoService ¶
type RedigoService struct { redis.Args Configuration Configuration // contains filtered or unexported fields }
RedigoService is the service which manages a Redis connection using the `redigo` library.
func (*RedigoService) ApplyConfiguration ¶
func (service *RedigoService) ApplyConfiguration(configuration interface{}) error
ApplyConfiguration applies a given configuration to the service.
func (*RedigoService) GetConn ¶
func (service *RedigoService) GetConn() (redis.Conn, error)
GetConn gets a connection from the pool.
func (*RedigoService) LoadConfiguration ¶
func (service *RedigoService) LoadConfiguration() (interface{}, error)
LoadConfiguration loading configuration from a repository.
func (*RedigoService) Publish ¶
func (service *RedigoService) Publish(ctx context.Context, channel string, data interface{}) error
Publish sends a data payload to a specific channel.
func (*RedigoService) Restart ¶
func (service *RedigoService) Restart() error
Restart stops and then starts the service again.
func (*RedigoService) RunWithConn ¶
func (service *RedigoService) RunWithConn(handler ConnHandler) error
RunWithConn acquires the connection from a pool ensuring it will be put back after the handler is done.
func (*RedigoService) Start ¶
func (service *RedigoService) Start() error
Start starts the redis pool.
func (*RedigoService) Stop ¶
func (service *RedigoService) Stop() error
Stop closes the connection pool.
func (*RedigoService) Subscribe ¶
func (service *RedigoService) Subscribe(ctx context.Context, subscribed SubscribedHandler, subscription SubscriptionHandler, channels ...string) error
Subscribe listens for messages on Redis pubsub channels. The subscribed function is called after the channels are subscribed. The subscription function is called for each message.
type SubscribedHandler ¶
type SubscribedHandler func() error
SubscribedHandler it called when all channels are subscribed.
type SubscriptionHandler ¶
SubscriptionHandler is called for each new message.