core

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_INSTANCES        = 16
	MAX_INSTANCES        = 1024
	MIN_PASS_LENGTH      = 6
	MAX_PASS_LENGTH      = 64
	MIN_DESC_LENGTH      = 6
	MAX_DESC_LENGTH      = 64
	MIN_PORT             = 1025
	MAX_PORT             = 65535
	MIN_PROCS            = 10240
	MIN_SOMAXCONN        = 2047
	MIN_STOP_DELAY       = 1      // 1 Sec
	MAX_STOP_DELAY       = 5 * 60 // 5 Min
	MIN_START_DELAY      = 1      // 1 Sec
	MAX_START_DELAY      = 5 * 60 // 5 Min
	MIN_THREADS          = 1
	MAX_THREADS          = 32
	MIN_CYCLE_TIME       = 15 * 60      // 15 Min
	MAX_CYCLE_TIME       = 24 * 60 * 60 // 1 Day
	MIN_CHANGES_NUM      = 1
	MAX_TAGS             = 3
	MIN_SYNC_WAIT        = 60          // 1 Min
	MAX_SYNC_WAIT        = 3 * 60 * 60 // 3 Hours
	MAX_FULL_START_DELAY = 30 * 60     // 30 Min
	MAX_SWITCH_WAIT      = 15 * 60     // 15 Min
	TOKEN_LENGTH         = 64
	MIN_SENTINEL_VERSION = 5
	MIN_NICE             = -20
	MAX_NICE             = 19
	MIN_IONICE_CLASS     = 0
	MAX_IONICE_CLASS     = 3
	MIN_IONICE_CLASSDATA = 0
	MAX_IONICE_CLASSDATA = 7
)

Limits

View Source
const (
	ROLE_MASTER   = "master"
	ROLE_MINION   = "minion"
	ROLE_SENTINEL = "sentinel"
)
View Source
const (
	SU_DATA_FILE            = "su.dat"
	REDIS_VERSION_DATA_FILE = "redis.dat"
	STATES_DATA_FILE        = "states.dat"
	IDS_DATA_FILE           = "ids.dat"
)
View Source
const (
	MAIN_MAX_INSTANCES               = "main:max-instances"
	MAIN_ALLOW_ID_REUSE              = "main:allow-id-reuse"
	MAIN_DISABLE_CONFIGURATION_CHECK = "main:disable-configuration-check"
	MAIN_DISABLE_FILESYSTEM_CHECK    = "main:disable-filesystem-check"
	MAIN_WARN_USED_MEMORY            = "main:warn-used-memory"
	MAIN_DIR                         = "main:dir"
	MAIN_MIN_PASS_LENGTH             = "main:min-pass-length"
	MAIN_STRICT_SECURE               = "main:strict-secure"
	MAIN_HOSTNAME                    = "main:hostname"

	LOG_LEVEL = "log:level"

	REDIS_BINARY           = "redis:binary"
	REDIS_USER             = "redis:user"
	REDIS_START_PORT       = "redis:start-port"
	REDIS_SAVE_ON_STOP     = "redis:save-on-stop"
	REDIS_NICE             = "redis:nice"
	REDIS_IONICE_CLASS     = "redis:ionice-class"
	REDIS_IONICE_CLASSDATA = "redis:ionice-classdata"

	SENTINEL_BINARY           = "sentinel:binary"
	SENTINEL_PORT             = "sentinel:port"
	SENTINEL_QUORUM           = "sentinel:quorum"
	SENTINEL_DOWN_AFTER       = "sentinel:down-after-milliseconds"
	SENTINEL_PARALLEL_SYNCS   = "sentinel:parallel-syncs"
	SENTINEL_FAILOVER_TIMEOUT = "sentinel:failover-timeout"

	TEMPLATES_REDIS    = "templates:redis"
	TEMPLATES_SENTINEL = "templates:sentinel"

	PATH_META_DIR   = "path:meta-dir"
	PATH_CONFIG_DIR = "path:config-dir"
	PATH_DATA_DIR   = "path:data-dir"
	PATH_PID_DIR    = "path:pid-dir"
	PATH_LOG_DIR    = "path:log-dir"

	REPLICATION_ROLE                = "replication:role"
	REPLICATION_MASTER_IP           = "replication:master-ip"
	REPLICATION_MASTER_PORT         = "replication:master-port"
	REPLICATION_AUTH_TOKEN          = "replication:auth-token"
	REPLICATION_FAILOVER_METHOD     = "replication:failover-method"
	REPLICATION_DEFAULT_ROLE        = "replication:default-role"
	REPLICATION_CHECK_READONLY_MODE = "replication:check-readonly-mode"
	REPLICATION_ALLOW_REPLICAS      = "replication:allow-replicas"
	REPLICATION_ALLOW_COMMANDS      = "replication:allow-commands"
	REPLICATION_ALWAYS_PROPAGATE    = "replication:always-propagate"
	REPLICATION_MAX_SYNC_WAIT       = "replication:max-sync-wait"
	REPLICATION_INIT_SYNC_DELAY     = "replication:init-sync-delay"

	DELAY_START = "delay:start"
	DELAY_STOP  = "delay:stop"
)
View Source
const (
	REDIS_USER_ADMIN    = "admin"
	REDIS_USER_SYNC     = "sync"
	REDIS_USER_SERVICE  = "service"
	REDIS_USER_SENTINEL = "sentinel"
)
View Source
const (
	BIN_RUNUSER = "/sbin/runuser"
)
View Source
const DEFAULT_FILE_PERMS = 0600

DEFAULT_FILE_PERMS is default permissions for files created by core

View Source
const META_VERSION = 1

META_VERSION is current meta version

View Source
const (
	PID_SENTINEL = "sentinel.pid"
)
View Source
const VERSION = "A1"

VERSION is current core version

Variables

View Source
var (
	ErrUnprivileged              = errors.New("RDS core requires root privileges")
	ErrSUAuthAlreadyExist        = errors.New("Superuser credentials already generated")
	ErrSUAuthIsEmpty             = errors.New("Superuser auth data can't be empty")
	ErrSUAuthNoData              = errors.New("Superuser auth data doesn't exist")
	ErrCantDiffConfigs           = errors.New("Instance should works for configs comparison")
	ErrEmptyIDDBPair             = errors.New("ID/DB value is empty")
	ErrCantReadPID               = errors.New("Can't read PID from PID file")
	ErrStateFileNotDefined       = errors.New("You must define path to states file")
	ErrInstanceStillWorks        = errors.New("Instance still works")
	ErrSentinelRoleSetNotAllowed = errors.New("This node must have master role for switching instance role")
	ErrSentinelWrongInstanceRole = errors.New("Instance must have a replica role")
	ErrIncompatibleFailover      = errors.New("Action can't be done due to incompatibility with failover method defined in the configuration file")
	ErrSentinelWrongVersion      = errors.New("Sentinel monitoring requires Redis 5 or greater")
	ErrSentinelCantStart         = errors.New("Can't start Sentinel process")
	ErrSentinelCantStop          = errors.New("Can't stop Sentinel process")
	ErrSentinelIsStopped         = errors.New("Sentinel is stopped")
	ErrSentinelCantSetRole       = errors.New("Can't set instance role - instance still have slave (replica) role")
	ErrMetaIsNil                 = errors.New("Meta struct is nil")
	ErrMetaNoID                  = errors.New("Meta must have valid ID")
	ErrMetaNoDesc                = errors.New("Meta must have valid description")
	ErrMetaNoAuth                = errors.New("Meta doesn't have auth info")
	ErrMetaNoPrefs               = errors.New("Meta doesn't have instance preferencies")
	ErrMetaNoConfigInfo          = errors.New("Meta doesn't have info about Redis configuration file")
	ErrMetaInvalidVersion        = errors.New("Meta must have valid version")
	ErrInvalidRedisVersionCache  = errors.New("Cache is invalid")
	ErrCantParseRedisVersion     = errors.New("Can't parse version of redis-server")
	ErrCantReadRedisCreationDate = errors.New("Can't read creation date of redis-server file")
	ErrCantReadDaemonizeOption   = errors.New("Can't read 'daemonize' option value from instance configuration file")
	ErrCantDaemonizeInstance     = errors.New("Impossible to run instance - 'daemonize' property set to 'no' in configuration file")
	ErrUnknownReplicationType    = errors.New("Unsupported replication type")
	ErrUnknownTemplateSource     = errors.New("Unknown template source")
)
View Source
var Config *knf.Config

Config is application config data

View Source
var User *system.User

User is current user info

Functions

func AddTag

func AddTag(id int, tag string) error

AddTag adds tag to instance

func CreateInstance

func CreateInstance(meta *InstanceMeta) error

CreateInstance create instance by instance meta

func DestroyInstance

func DestroyInstance(id int) error

DestroyInstance destroy (delete) instance

func ExecCommand

func ExecCommand(id int, req *REDIS.Request) (*REDIS.Resp, error)

ExecCommand executes Redis command on given instance

func GenPassword

func GenPassword() string

GenPassword generates secure password with random length (16-28)

func GenerateToken

func GenerateToken() string

GenerateToken generates unique token for sync daemon

func GetAvailableInstanceID

func GetAvailableInstanceID() int

GetAvailableInstanceID returns available instance ID

func GetInstanceAOFPath

func GetInstanceAOFPath(id int) string

GetInstanceAOFPath returns path to the append only file

func GetInstanceConfig

func GetInstanceConfig(id int, timeout time.Duration) (*REDIS.Config, error)

GetInstanceConfig read and parse instance in-memory config

func GetInstanceConfigChanges

func GetInstanceConfigChanges(id int) ([]REDIS.ConfigPropDiff, error)

GetInstanceConfigChanges returns difference between file config and in-memory config

func GetInstanceConfigFilePath

func GetInstanceConfigFilePath(id int) string

GetInstanceConfigFilePath returns path to config file for instance with given ID

func GetInstanceConfigHash

func GetInstanceConfigHash(id int) (string, error)

GetInstanceConfigHash returns Redis config file SHA-256 hash

func GetInstanceDataDirPath

func GetInstanceDataDirPath(id int) string

GetInstanceDataDirPath returns path to data directory for instance with given ID

func GetInstanceIDList

func GetInstanceIDList() []int

GetInstanceIDList returns sorted slice with all instance ID's

func GetInstanceIDListByState

func GetInstanceIDListByState(state State) ([]int, error)

GetInstanceIDListByState returns sorted slice with instance ID's filtered by state

func GetInstanceInfo

func GetInstanceInfo(id int, timeout time.Duration, all bool) (*REDIS.Info, error)

GetInstanceInfo returns info from instance

func GetInstanceLogDirPath

func GetInstanceLogDirPath(id int) string

GetInstanceLogDirPath returns path to logs directory for instance with given ID

func GetInstanceLogFilePath

func GetInstanceLogFilePath(id int) string

GetInstanceLogFilePath returns path to log file for instance with given ID

func GetInstanceMetaFilePath

func GetInstanceMetaFilePath(id int) string

GetInstanceMetaFilePath returns path to meta file for instance with given ID

func GetInstancePID

func GetInstancePID(id int) int

GetInstancePID returns PID of given instance

func GetInstancePIDFilePath

func GetInstancePIDFilePath(id int) string

GetInstancePIDFilePath returns path to PID file for instance with given ID

func GetInstancePort

func GetInstancePort(id int) int

GetInstancePort returns port used by redis for given instance

func GetInstanceRDBPath

func GetInstanceRDBPath(id int) string

GetInstanceRDBPath returns path to the instance dump file

func GetInstanceStartDate

func GetInstanceStartDate(id int) int64

GetInstanceStartDate returns timestamp when instance was started

func GetInstanceVersion

func GetInstanceVersion(id int) version.Version

GetInstanceVersion return instance Redis version

func GetRedisVersion

func GetRedisVersion() (version.Version, error)

GetRedisVersion returns current installed Redis version

func GetStatesFilePath

func GetStatesFilePath() string

GetStatesFilePath returns path to global states file

func HasInstanceData

func HasInstanceData(id int) bool

HasInstanceData returns true if instance data is present on FS

func HasInstances

func HasInstances() bool

HasInstances returns true if that at least one instance exists

func HasSUAuth

func HasSUAuth() bool

HasSUAuth returns true if superuser auth data exists

func Init

func Init(conf string) []error

Init starts initialization routine

func IsFailoverMethod

func IsFailoverMethod(method FailoverMethod) bool

IsFailoverMethod returns true if given failover method is used

func IsInstanceExist

func IsInstanceExist(id int) bool

IsInstanceExist returns true if instance exists

func IsMaster

func IsMaster() bool

IsMaster returns true if role of current RDS node has role "master"

func IsMinion

func IsMinion() bool

IsMinion returns true if role of current RDS node has role "minion"

func IsOutdated

func IsOutdated(id int) bool

IsOutdated returns true if instance outdated

func IsSentinel

func IsSentinel() bool

IsSentinel returns true if role of current RDS node has role "sentinel"

func IsSentinelActive

func IsSentinelActive() bool

IsSentinelActive returns true if Sentinel is works

func IsSentinelMonitors

func IsSentinelMonitors(id int) bool

IsSentinelMonitors returns true if Sentinel monitoring instance with given ID

func IsSyncDaemonActive

func IsSyncDaemonActive() bool

IsSyncDaemonActive returns true if sync daemon is works

func IsSyncDaemonInstalled

func IsSyncDaemonInstalled() bool

IsSyncDaemonInstalled returns true if sync daemon is installed

func IsValidTag

func IsValidTag(tag string) bool

IsValidTag validates tag

func KillInstance

func KillInstance(id int) error

KillInstance send KILL signal to Redis

func ParseIDDBPair

func ParseIDDBPair(pair string) (int, int, error)

ParseIDDBPair parse ID/DB pair (id:db id/db)

func ParseTag

func ParseTag(tag string) (string, string)

ParseTag parse tag and returns tag and color

func ReadInstanceConfig

func ReadInstanceConfig(id int) (*REDIS.Config, error)

ReadInstanceConf read and parse redis config for given instance

func RegenerateInstanceConfig

func RegenerateInstanceConfig(id int) error

RegenerateInstanceConfig regenerate redis config file for given instance

func ReloadConfig

func ReloadConfig() []error

ReloadConfig reloads RDS configuration

func ReloadInstanceConfig

func ReloadInstanceConfig(id int) []error

ReloadInstanceConfig reload instance config

func RemoveTag

func RemoveTag(id int, tag string) error

RemoveTag remove tag associated with instance

func ReopenLog

func ReopenLog() error

ReopenLog reopen log (close+open) file for log rotation purposes

func SaveSUAuth

func SaveSUAuth(auth *SuperuserAuth, rewrite bool) error

SaveSUAuth save superuser auth data

func SaveStates

func SaveStates(file string) error

SaveStates save all instances states to file

func SentinelCheck

func SentinelCheck(id int) (string, bool)

SentinelCheck returns message about checking Sentinel quorum status

func SentinelInfo

func SentinelInfo(id int) (*SENTINEL.Info, error)

SentinelInfo returns info from Sentinel about master, replicas and sentinels

func SentinelMasterIP

func SentinelMasterIP(id int) (string, error)

SentinelMasterIP returns IP of master instance

func SentinelMasterSwitch

func SentinelMasterSwitch(id int) error

SentinelMasterSwitch can be used if you want to set role of current local instance to master. This command temporary set slave priority to 1 and force failover.

func SentinelReset

func SentinelReset() error

SentinelReset reset master state in Sentinel for all instances

func SentinelStart

func SentinelStart() []error

SentinelStart start (run) Sentinel daemon

func SentinelStartMonitoring

func SentinelStartMonitoring(id int) error

SentinelStartMonitoring add instance to Sentinel monitoring

func SentinelStop

func SentinelStop() error

SentinelStop stop (shutdown) Sentinel daemon

func SentinelStopMonitoring

func SentinelStopMonitoring(id int) error

SentinelStopMonitoring remove instance from Sentinel monitoring

func SetLogOutput

func SetLogOutput(file, minLevel string, bufIO bool) error

SetLogOutput setup log output

func Shutdown

func Shutdown(code int)

Shutdown safely shutdown app

func StartInstance

func StartInstance(id int, controlLoading bool) error

StartInstance starting instance If controlLoading set to true, instance marked as started only after starting, finishing loading and syncing with master

func StopInstance

func StopInstance(id int, force bool) error

StopInstance stopping instance

func UpdateInstance

func UpdateInstance(newMeta *InstanceMeta) error

UpdateInstance update instance meta For security purposes only some part of fields from given meta is used for update

func ValidateTemplates added in v1.2.0

func ValidateTemplates() []error

ValidateTemplates validates templates for Redis and Sentinel

Types

type FailoverMethod

type FailoverMethod string
const (
	FAILOVER_METHOD_STANDBY  FailoverMethod = "standby"
	FAILOVER_METHOD_SENTINEL FailoverMethod = "sentinel"
)

type IDSInfo

type IDSInfo struct {
	LastID int `json:"last_id"`
}

type InstanceAuth

type InstanceAuth struct {
	User   string `json:"user"`
	Pepper string `json:"pepper"`
	Hash   string `json:"hash"`
}

func NewInstanceAuth

func NewInstanceAuth(password string) (*InstanceAuth, error)

NewAuthInfo generates new instance auth struct

type InstanceConfigInfo

type InstanceConfigInfo struct {
	Hash string `json:"hash"`
	Date int64  `json:"date"`
}

type InstanceInfo

type InstanceInfo struct {
	Meta  *InstanceMeta `json:"meta"`
	State State         `json:"state"`
}

type InstanceMeta

type InstanceMeta struct {
	Tags         []string              `json:"tags,omitempty"`       // List of tags
	Desc         string                `json:"desc"`                 // Description
	UUID         string                `json:"uuid"`                 // UUID
	Compatible   string                `json:"compatible,omitempty"` // Compatible redis version
	MetaVersion  int                   `json:"meta_version"`         // Meta information version
	ID           int                   `json:"id"`                   // Instance ID
	Created      int64                 `json:"created"`              // Date of creation (unix timestamp)
	Preferencies *InstancePreferencies `json:"preferencies"`         // Config data
	Config       *InstanceConfigInfo   `json:"config"`               // Config info (hash + creation date)
	Auth         *InstanceAuth         `json:"auth"`                 // Instance auth info
	Storage      Storage               `json:"storage,omitempty"`    // Core version agnostic data storage
}

func GetInstanceMeta

func GetInstanceMeta(id int) (*InstanceMeta, error)

GetInstanceMeta returns meta info struct for given instance

func NewInstanceMeta

func NewInstanceMeta(instancePassword, servicePassword string) (*InstanceMeta, error)

NewInstanceMeta generates meta struct for new instance

func (*InstanceMeta) Validate

func (m *InstanceMeta) Validate() error

Validate validate meta struct

type InstancePreferencies

type InstancePreferencies struct {
	AdminPassword    string          `json:"admin_password,omitempty"`   // Admin user password
	SyncPassword     string          `json:"sync_password,omitempty"`    // Sync user password
	ServicePassword  string          `json:"service_password,omitempty"` // Service user password
	SentinelPassword string          `json:"sentinel_password"`          // Sentinel user password
	ReplicationType  ReplicationType `json:"replication_type"`           // Replication type
	IsSaveDisabled   bool            `json:"is_save_disabled"`           // Disabled saves flag
}

type MetaCache

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

MetaCache is instance metadata cache

func NewMetaCache

func NewMetaCache(maxCacheTime time.Duration) *MetaCache

NewMetaCache creates new meta cache

func (*MetaCache) Get

func (c *MetaCache) Get(key int) (*InstanceMeta, bool)

Get returns meta from cache if exist

func (*MetaCache) Has

func (c *MetaCache) Has(key int) bool

Has checks that we have cached meta for instance

func (*MetaCache) Remove

func (c *MetaCache) Remove(key int)

Remove removes item from cache

func (*MetaCache) Set

func (c *MetaCache) Set(key int, meta *InstanceMeta)

Set adds metadata to cache

type MetaCacheItem

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

MetaCacheItem contains instance metadata and date of creation

type RedisVersionInfo

type RedisVersionInfo struct {
	CDate   int64  `json:"cdate"`
	Version string `json:"version"`
}

type ReplicationType

type ReplicationType string
const (
	REPL_TYPE_REPLICA ReplicationType = "replica"
	REPL_TYPE_STANDBY ReplicationType = "standby"
)

func (ReplicationType) IsReplica

func (t ReplicationType) IsReplica() bool

IsReplica returns true if replication type is replica

func (ReplicationType) IsStandby

func (t ReplicationType) IsStandby() bool

IsStandby returns true if replication type is standby

type State

type State uint16
const (
	INSTANCE_STATE_UNKNOWN State = 0
	INSTANCE_STATE_STOPPED State = 1 << iota
	INSTANCE_STATE_WORKS
	INSTANCE_STATE_DEAD
	INSTANCE_STATE_IDLE         // Extended
	INSTANCE_STATE_SYNCING      // Extended
	INSTANCE_STATE_LOADING      // Extended
	INSTANCE_STATE_SAVING       // Extended
	INSTANCE_STATE_HANG         // Extended
	INSTANCE_STATE_ABANDONED    // Extended
	INSTANCE_STATE_MASTER_UP    // Extended
	INSTANCE_STATE_MASTER_DOWN  // Extended
	INSTANCE_STATE_NO_REPLICA   // Extended
	INSTANCE_STATE_WITH_REPLICA // Extended
	INSTANCE_STATE_WITH_ERRORS  // Extended
)

func GetInstanceState

func GetInstanceState(id int, extended bool) (State, error)

GetInstanceState returns state of instance

func (State) IsAbandoned added in v1.3.0

func (s State) IsAbandoned() bool

IsAbandoned returns true if instance abandoned (no traffic for long time)

func (State) IsDead

func (s State) IsDead() bool

IsDead returns true if instance dead (pid exist, but process not exist)

func (State) IsHang

func (s State) IsHang() bool

IsHang returns true if instance blocked by some command

func (State) IsIdle

func (s State) IsIdle() bool

IsIdle returns true if instance is idle

func (State) IsLoading

func (s State) IsLoading() bool

IsLoading returns true if instance loading rds into memory

func (State) IsMasterDown added in v1.3.0

func (s State) IsMasterDown() bool

IsMasterDown returns true if instance master is down

func (State) IsMasterUp added in v1.3.0

func (s State) IsMasterUp() bool

IsMasterUp returns true if instance master is up

func (State) IsSaving

func (s State) IsSaving() bool

IsSaving returns true if instance saving data on disk

func (State) IsStopped

func (s State) IsStopped() bool

IsStopped returns true if instance stopped

func (State) IsSyncing

func (s State) IsSyncing() bool

IsSyncing returns true if instance syncing with master/slave

func (State) IsWorks

func (s State) IsWorks() bool

IsWorks returns true if instance works

func (State) NoReplica added in v1.3.0

func (s State) NoReplica() bool

func (State) WithErrors added in v1.3.0

func (s State) WithErrors() bool

func (State) WithReplica added in v1.3.0

func (s State) WithReplica() bool

type StateInfo

type StateInfo struct {
	ID    int   `json:"id"`
	State State `json:"state"`
}

type StatesInfo

type StatesInfo struct {
	States   []StateInfo `json:"states"`
	Sentinel bool        `json:"sentinel"`
}

func ReadStates

func ReadStates(file string) (*StatesInfo, error)

ReadStates read states info from file

type Stats

type Stats struct {
	Instances *StatsInstances `json:"instances"`
	Clients   *StatsClients   `json:"clients"`
	Memory    *StatsMemory    `json:"memory"`
	Overall   *StatsOverall   `json:"overall"`
	Keys      *StatsKeys      `json:"keys"`
}

func GetStats

func GetStats() *Stats

GetStats returns overall stats

type StatsClients

type StatsClients struct {
	Connected uint64 `json:"connected_clients"`
	Blocked   uint64 `json:"blocked_clients"`
}

type StatsInstances

type StatsInstances struct {
	Total         uint64 `json:"total_instances"`          // Total number of instances
	Active        uint64 `json:"active_instances"`         // Working instances
	Dead          uint64 `json:"dead_instances"`           // Dead instances
	BgSave        uint64 `json:"bgsave_instances"`         // Instances which save data in the background
	Syncing       uint64 `json:"syncing_instances"`        // Instances which currently sync data with master or replica
	AOFRewrite    uint64 `json:"aof_rewrite_instances"`    // Instances which currently rewrite aof data
	SaveFailed    uint64 `json:"save_failed_instances"`    // Instances with failed save
	ActiveMaster  uint64 `json:"active_master_instances"`  // Instances with active sync as a master
	ActiveReplica uint64 `json:"active_replica_instances"` // Instances with active sync as a replica
	Outdated      uint64 `json:"outdated_instances"`       // Outdated instances (newer version is installed but not used)
}

type StatsKeys

type StatsKeys struct {
	Total   uint64 `json:"total_keys"`
	Expires uint64 `json:"expires_keys"`
}

type StatsMemory

type StatsMemory struct {
	SystemMemory  uint64 `json:"system_memory"`
	SystemSwap    uint64 `json:"system_swap"`
	UsedMemory    uint64 `json:"used_memory"`
	UsedMemoryRSS uint64 `json:"used_memory_rss"`
	UsedMemoryLua uint64 `json:"used_memory_lua"`
	UsedSwap      uint64 `json:"used_swap"`
	IsSwapEnabled bool   `json:"is_swap_enabled"`
}

type StatsOverall

type StatsOverall struct {
	TotalConnectionsReceived uint64 `json:"total_connections_received"`
	TotalCommandsProcessed   uint64 `json:"total_commands_processed"`
	InstantaneousOpsPerSec   uint64 `json:"instantaneous_ops_per_sec"`
	InstantaneousInputKbps   uint64 `json:"instantaneous_input_kbps"`
	InstantaneousOutputKbps  uint64 `json:"instantaneous_output_kbps"`
	RejectedConnections      uint64 `json:"rejected_connections"`
	ExpiredKeys              uint64 `json:"expired_keys"`
	EvictedKeys              uint64 `json:"evicted_keys"`
	KeyspaceHits             uint64 `json:"keyspace_hits"`
	KeyspaceMisses           uint64 `json:"keyspace_misses"`
	PubsubChannels           uint64 `json:"pubsub_channels"`
	PubsubPatterns           uint64 `json:"pubsub_patterns"`
}

type Storage

type Storage map[string]string

Storage is version agnostic KV data storage

func (Storage) Delete

func (s Storage) Delete(key string)

Delete removes data for given key

func (Storage) Get

func (s Storage) Get(key string) string

Get returns value for given key

func (Storage) GetB

func (s Storage) GetB(key string) (bool, error)

GetB returns boolean value for given key

func (Storage) GetF

func (s Storage) GetF(key string) (float64, error)

GetF returns float value for given key

func (Storage) GetI

func (s Storage) GetI(key string) (int, error)

GetI returns integer value for given key

func (Storage) GetU

func (s Storage) GetU(key string) (uint64, error)

GetU returns uint value for given key

func (Storage) Has

func (s Storage) Has(key string) bool

Has checks if record with given key is exist in storage

func (Storage) IsEmpty

func (s Storage) IsEmpty() bool

IsEmpty returns true if storage is empty

func (Storage) Set

func (s Storage) Set(key, value string)

Set sets value for given key

func (Storage) SetB

func (s Storage) SetB(key string, value bool)

SetB sets boolean value for given key

func (Storage) SetF

func (s Storage) SetF(key string, value float64)

SetF sets float value for given key

func (Storage) SetI

func (s Storage) SetI(key string, value int)

SetI sets integer value for given key

func (Storage) SetU

func (s Storage) SetU(key string, value uint64)

SetU sets uint value for given key

type SuperuserAuth

type SuperuserAuth struct {
	Pepper string `json:"pepper"`
	Hash   string `json:"hash"`
}

func NewSUAuth

func NewSUAuth() (string, *SuperuserAuth, error)

NewSUAuth generates new superuser auth data

func ReadSUAuth

func ReadSUAuth() (*SuperuserAuth, error)

ReadSUAuth read superuser auth data

type SystemStatus

type SystemStatus struct {
	HasProblems     bool
	HasTHPIssues    bool
	HasKernelIssues bool
	HasLimitsIssues bool
	HasFSIssues     bool
}

func GetSystemConfigurationStatus

func GetSystemConfigurationStatus(force bool) (SystemStatus, error)

GetSystemConfigurationStatus returns system configuration status

type TemplateSource added in v1.2.0

type TemplateSource string
const (
	TEMPLATE_SOURCE_REDIS    TemplateSource = "redis.conf"
	TEMPLATE_SOURCE_SENTINEL TemplateSource = "sentinel.conf"
)

Jump to

Keyboard shortcuts

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