redis

package
v0.0.0-...-ea2d1eb Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachSentinelToMaster

func AttachSentinelToMaster(sentinel Client, masterIP string, cluster *Cluster) error

AttachSentinelToMaster Configures a sentinel to monitor a master

func ConfigureSentinel

func ConfigureSentinel(client Client, cluster *Cluster) error

ConfigureSentinel Configures the sentinel with settings

func IsWorkingInstance

func IsWorkingInstance(client Client) (bool, error)

IsWorkingInstance Checks that a registered IP is up and running. Blocking

func SentinelMonitorCommand

func SentinelMonitorCommand(
	sentinel Client,
	masterName string,
	masterIP string,
	redisPort string,
) *redis.StringCmd

SentinelMonitorCommand Configures sentinal instance to monitor a new master

func SentinelSetCommand

func SentinelSetCommand(
	client Client,
	masterName string,
	key string,
	value string,
) *redis.StringCmd

SentinelSetCommand Configures sentinel instance with key value

func SetupCluster

func SetupCluster(cluster *Cluster)

SetupCluster Works with the registered entities and starts the cluster when ready

Types

type Client

type Client interface {
	String() string
	Ping() *redis.StatusCmd
	Options() *redis.Options
	SlaveOf(host, port string) *redis.StatusCmd
	Process(redis.Cmder) error
	Close() error
}

Client Interface to our Redis library

func ConnectToClient

func ConnectToClient(options *redis.Options) Client

ConnectToClient Connects to a Redis server

func ConnectToRedis

func ConnectToRedis(ip string, port string, config Config) Client

ConnectToRedis Connects to a Redis server

func ConnectToSentinel

func ConnectToSentinel(ip string, port string, config Config) Client

ConnectToSentinel Connects to a Redis server

type Cluster

type Cluster struct {
	Config Config

	Sentinels []Sentinel
	Redii     []Redis
}

Cluster information that

func NewCluster

func NewCluster(config Config) *Cluster

NewCluster Creates a new Redis cluster object configured with config

func (*Cluster) AddRedis

func (c *Cluster) AddRedis(ip string)

AddRedis Adds a redis instance via IP address

func (*Cluster) AddSentinel

func (c *Cluster) AddSentinel(ip string)

AddSentinel Adds a sentinel registration via IP address

func (*Cluster) IsFunctional

func (c *Cluster) IsFunctional() (bool, error)

IsFunctional Test the cluster to see if it has a defined and functioning master

type Config

type Config struct {
	Master string `json:"master"`

	Redis ConfigRedis `json:"redis"`

	Sentinel struct {
		Hostname string                 `json:"hostname"`
		Port     int                    `json:"port"`
		Config   map[string]interface{} `json:"config"`
	} `json:"sentinel"`
}

Config Configuration structure pulled from JSON file

func (*Config) ConvertToString

func (c *Config) ConvertToString(data interface{}) (string, error)

ConvertToString Takes an interface value and ensures it's a string

type ConfigRedis

type ConfigRedis struct {
	Hostname string `json:"hostname"`
	Port     int    `json:"port"`
	Password string `json:"password"`
}

ConfigRedis Configuration structure of Redis instance

func (*ConfigRedis) MarshalJSON

func (r *ConfigRedis) MarshalJSON() ([]byte, error)

MarshalJSON Converts our password to a blank on output

type Redis

type Redis struct {
	IP string `json:"ip"`
}

Redis class

type Sentinel

type Sentinel struct {
	IP string `json:"ip"`
}

Sentinel class

Jump to

Keyboard shortcuts

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