dynomite

package
v0.0.0-...-4343951 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListBackups

func ListBackups(containerName, prefix string, limit int) error

ListBackups shows the possible restore candidates

func Restore

func Restore(containerName, prefix string) error

Restore downloads the latest backup to disk

Types

type Collector

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

Collector implements the prometheus.Collector interface.

func NewCollector

func NewCollector(dyno *Dynomite) *Collector

NewCollector creates a new Collector.

func (*Collector) Collect

func (c *Collector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Collector) Describe

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type Dynomite

type Dynomite struct {
	Host    string
	Port    int16
	Backend *Redis
}

Dynomite represents a dynomite instance

func NewDynomite

func NewDynomite(host string, port int16) *Dynomite

NewDynomite returns a new instance of Dynomite

func NewDynomiteRedis

func NewDynomiteRedis(host string, port, backendPort int16, password string) *Dynomite

NewDynomiteRedis creates a new Redis struct with initialized ConnectionPool

func (Dynomite) Backup

func (dyno Dynomite) Backup(containerName, prefix string) error

Backup triggers a BGSAVE and uploads the dumpfile to Swift

func (Dynomite) BackupEvery

func (dyno Dynomite) BackupEvery(every time.Duration, containerName, prefix string) error

BackupEvery calls Backup() periodicly

func (Dynomite) GetState

func (dyno Dynomite) GetState() (State, error)

GetState retrieves dynomite internal state

func (Dynomite) Info

func (dyno Dynomite) Info() (*InfoReport, error)

Info returns the InfoReport for a Dynomite instance.

func (Dynomite) SetState

func (dyno Dynomite) SetState(state State) (string, error)

SetState sets Dynomite's internal state and returns the response status, if successful.

func (Dynomite) Warmup

func (dyno Dynomite) Warmup(master Redis, accecptedDiff int64, timeout time.Duration, slaveHost string) (bool, error)

Warmup starts the warmup process 1. Set Dynomite in Standby mode 2. Set Dynomite Backend as replica of master 3. Wait for accecptable replication offset difference between master and replica or timeout 4. Set Dynomite State to write_only 5. Stop replication 6. Set Dynomite State to resuming 7. Set Dynomite State to normal

type InfoReport

type InfoReport struct {
	Uptime uint64 `json:"uptime"`
	Rack   string `json:"rack"`
	DC     string `json:"dc"`
	Pool   struct {
		ClientConnections     uint64 `json:"client_connections"`
		ClientReadRequests    uint64 `json:"client_read_requests"`
		ClientWriteRequests   uint64 `json:"client_write_requests"`
		ClientDroppedRequests uint64 `json:"client_dropped_requests"`
	} `json:"dyn_o_mite"`
}

InfoReport contains the information as reported by the /info endpoint of a Dynomite instance.

type Redis

type Redis struct {
	Host string
	Port int16
	// contains filtered or unexported fields
}

Redis represent the dynomite backend as Redis instance

func NewRedis

func NewRedis(host string, port int16, password string) *Redis

NewRedis creates a new Redis struct with initialized ConnectionPool

func (Redis) BGSave

func (r Redis) BGSave(timeout time.Duration) (time.Time, error)

BGSave triggers Background Save and watches the status

func (Redis) DBSize

func (r Redis) DBSize() (int64, error)

DBSize retrieves the number of Keys in the Backend

func (Redis) LastSave

func (r Redis) LastSave() (time.Time, error)

LastSave return the Time of the last save

func (Redis) Ping

func (r Redis) Ping() (bool, error)

Ping checks liveness od Redis

func (Redis) Replicate

func (r Redis) Replicate(master Redis) (bool, error)

Replicate activates replication from the given master

func (Redis) ReplicationOffsets

func (r Redis) ReplicationOffsets(slaveHost string) (*ReplicationOffsets, error)

ReplicationOffsets determines the ReplicationOffset difference between master and slave

func (Redis) Role

func (r Redis) Role() (string, error)

Role returns the current role of Redis master/slave

func (Redis) StopReplication

func (r Redis) StopReplication() error

StopReplication activates replication from the given master

func (Redis) WaitFor

func (r Redis) WaitFor(timeout time.Duration) error

WaitFor waits for a succesful Ping to the backend during the specified timeout

func (Redis) Warmup

func (r Redis) Warmup(master Redis, accecptedDiff int64, timeout time.Duration, slaveHost string) (bool, error)

Warmup does a simple replication from a master backend without dealing with dynomite states

type ReplicationOffsets

type ReplicationOffsets struct {
	Master int64
	Slave  int64
}

ReplicationOffsets represents the current state of replication of master and slave

type State

type State string

State representing the working mode of dynomite

const (
	Normal     State = "normal"
	Standby    State = "standby"
	WritesOnly State = "writes_only"
	Resuming   State = "resuming"
)

Possible states of dynomite

func StrToState

func StrToState(str string) (State, error)

StrToState validates and converts a string to a State.

Jump to

Keyboard shortcuts

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