redigosrv

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: MIT Imports: 7 Imported by: 1

README

CircleCI codecov

go-rscsrv-redigo

The go-rscsrv-redigo is the lab259/go-rscsrv service implementation for the gomodule/redigo library.

Dependencies

It depends on the lab259/go-rscsrv (and its dependencies, of course) itself and the gomodule/redigo library.

Installation

First, fetch the library to the repository.

go get github.com/lab259/go-rscsrv-redigo

Usage

TODO

Documentation

Index

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

type SubscriptionHandler func(channel string, data []byte) error

SubscriptionHandler is called for each new message.

Jump to

Keyboard shortcuts

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