redis

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Port is a standard Redis port. Is not meant to change
	Port = 6379

	// MinimumFailoverSize sets the minimum desired size of Redis replication.
	// It reflects a simple master - replica pair.
	// Due to the highly volatile nature of Kubernetes environments
	// it is better to keep at least 3 instances and feel free to lose one instance for whatever reason.
	// It is especially useful for scenarios when there is no need or permission to use persistent storage.
	// In such cases it is safe to run Redis replication failover and the risk of losing data is minimal.
	MinimumFailoverSize = 2

	// Roles as seen in the info replication output
	RoleMaster  = "role:master"
	RoleReplica = "role:slave"

	// DefaultFailoverTimeout sets the maximum timeout for the exponential backoff timer
	DefaultFailoverTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Host string
	Port string
}

Address represents the Host:Port pair of a instance instance

func (Address) String

func (a Address) String() string

type Replication added in v0.1.0

type Replication interface {
	// Reconfigure checks the state of replication and reconfigures instances if needed
	Reconfigure() error
	// Size returns the total number of replicas
	Size() int
	// GetMasterAddress returns the current master address
	GetMasterAddress() Address
	// Refresh refreshes replication info for every instance
	Refresh() error
	// Disconnect closes connections to all instances
	Disconnect()
	// contains filtered or unexported methods
}

Replication is the interface for checking the status of replication

func New added in v0.1.0

func New(password string, addresses ...Address) (Replication, error)

New creates a new redis replication. Instances are added on the best effort basis. It means that out of N addresses passed if at least 2 instances are healthy the replication will be created. Otherwise New will return an error.

Jump to

Keyboard shortcuts

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