redigoring

package module
v0.0.0-...-b3a0bfd Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: BSD-2-Clause Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

redigoring

redigoring is consistent hashing implementation for redigo redis pool, used to distribute keys across multiple Redis servers using consistent hashing algorithm.

Features

  • distributes the keys using consistent hashing
  • auto disable/enable pool based on the health check result

References

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyPools returned when there is no available pool
	// needed for the respective operation
	ErrEmptyPools = errors.New("empty pools")

	// ErrPoolNotFound returned when there is no pool with the given key
	ErrPoolNotFound = errors.New("pool not found")
)
View Source
var (
	// DefaultHealtCheckInterval is the default value for the health check interval
	DefaultHealtCheckInterval = 3 * time.Second
)

Functions

This section is empty.

Types

type Option

type Option func(*Ring)

Option represents optional option of the redigoring

func WithHealthCheckInterval

func WithHealthCheckInterval(dur time.Duration) Option

WithHealthCheckInterval sets the healt check interval to the given duration

type Ring

type Ring struct {
	// contains filtered or unexported fields
}

Ring represent the redigo ring

func New

func New(ctx context.Context, pools map[string]*redis.Pool, opts ...Option) (*Ring, error)

New creates new redigo ring object

func (*Ring) Add

func (r *Ring) Add(name string, pool *redis.Pool)

Add adds a pool with the given name to the ring

func (*Ring) GetConn

func (r *Ring) GetConn(key string) (redis.Conn, error)

GetConn get connection for the given key

func (*Ring) GetPool

func (r *Ring) GetPool(key string) (string, *redis.Pool, error)

GetPool returns pool for given key. Except you want to know the location of your key, you can use `GetConn` directly.

func (*Ring) Remove

func (r *Ring) Remove(name string) (*redis.Pool, error)

Remove removes a pool with given name from the ring

Jump to

Keyboard shortcuts

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