redis

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(s bandmaster.Service) *redis.Pool

Client returns the underlying `redis.Pool` of the given service.

It assumes that the service is ready; i.e. it might return nil if it's actually not.

NOTE: This will panic if `s` is not a `redis.Service`.

func New

func New(p *redis.Pool) bandmaster.Service

New creates a new Redis service using the provided `redis.Pool`. You may use the helpers for environment-based configuration to get a pre-configured `redis.Pool` with sane defaults.

It doesn't open any connection nor does it do any kind of I/O; i.e. it cannot fail.

Types

type Env

type Env struct {
	URI            string        `envconfig:"URI" default:"redis://localhost:6379"`
	MaxConnsIdle   int           `envconfig:"MAX_CONNS_IDLE" default:"32"`
	MaxConnsActive int           `envconfig:"MAX_CONNS_ACTIVE" default:"32"`
	TimeoutIdle    time.Duration `envconfig:"TIMEOUT_IDLE" default:"45s"`
	TimeoutRead    time.Duration `envconfig:"TIMEOUT_READ" default:"2s"`
	TimeoutWrite   time.Duration `envconfig:"TIMEOUT_WRITE" default:"2s"`
	Wait           bool          `envconfig:"WAIT" default:"true"`
}

Env can be used to configure a Redis session via the environment.

It comes with sane defaults for a local development set-up.

func NewEnv

func NewEnv(prefix string) (*Env, error)

NewEnv parses the environment and returns a new `Env` structure.

`prefix` defines the prefix for the environment keys, e.g. with a 'XX' prefix, 'REPLICAS' would become 'XX_REPLICAS'.

func (*Env) Config

func (e *Env) Config() *redis.Pool

Config returns a `redis.Pool` using the values from the environment.

type Service

type Service struct {
	*bandmaster.ServiceBase // "inheritance"
	// contains filtered or unexported fields
}

Service implements a Redis service based on the 'garyburd/redigo' package.

func (*Service) Start

Start opens a connection and PINGs the server: if everything goes smoothly, the service is marked as 'started'; otherwise, an error is returned.

Start is used by BandMaster's internal machinery, it shouldn't ever be called directly by the end-user of the service.

func (*Service) Stop

func (s *Service) Stop(context.Context) error

Stop does nothing.

Stop is used by BandMaster's internal machinery, it shouldn't ever be called directly by the end-user of the service.

Jump to

Keyboard shortcuts

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