redis

package
v0.0.0-...-c283e9f Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: BSD-3-Clause Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultPort        = "6379"
	DefaultBinDir      = "/usr/bin"
	DefaultDataDir     = "/data"
	DefaultPassword    = ""
	DefaultOpTimeout   = 5 * time.Minute
	DefaultReplTimeout = 1 * time.Minute
)

Variables

View Source
var (
	// ErrTimeout is returned when an operation times out.
	ErrTimeout = errors.New("timeout")

	// ErrRunning is returned when starting an already running process.
	ErrRunning = errors.New("redis already running")

	// ErrStopped is returned when stopping an already stopped process.
	ErrStopped = errors.New("redis already stopped")
)

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Process     *Process
	Heartbeater discoverd.Heartbeater
	Logger      log15.Logger
	// contains filtered or unexported fields
}

Handler represents an HTTP handler for the redis process.

func NewHandler

func NewHandler() *Handler

NewHandler returns a new instance of Handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP serves an HTTP request and returns a response.

type Process

type Process struct {
	ID           string
	Singleton    bool
	Port         string
	BinDir       string
	DataDir      string
	Password     string
	OpTimeout    time.Duration
	ReplTimeout  time.Duration
	Logger       log15.Logger
	WaitUpstream bool
	// contains filtered or unexported fields
}

Process represents a running Redis process.

func NewProcess

func NewProcess() *Process

NewProcess returns a new instance of Process with defaults.

func (*Process) ConfigPath

func (p *Process) ConfigPath() string

ConfigPath returns the path to the redis.conf.

func (*Process) Info

func (p *Process) Info() (*ProcessInfo, error)

Info returns information about the process.

func (*Process) RedisInfo

func (p *Process) RedisInfo(addr string, timeout time.Duration) (*RedisInfo, error)

RedisInfo executes an INFO command against a Redis server and returns the results.

func (*Process) Restore

func (p *Process) Restore(r io.Reader) error

Restore stops the process, copies an RDB from r, and restarts the process. Redis automatically handles recovery when there's a dump.rdb file present.

func (*Process) Start

func (p *Process) Start() error

Start begins the process. Returns an error if the process is already running.

func (*Process) Stop

func (p *Process) Stop() error

Stop attempts to gracefully stop the process. If the process cannot be stopped gracefully then it is forcefully stopped. Returns an error if the process is already stopped.

type ProcessInfo

type ProcessInfo struct {
	Running bool `json:"running"`
}

ProcessInfo represents state about the process returned by Process.Info().

type RedisInfo

type RedisInfo struct {
	Role string // role

	MasterHost       string        // master_host
	MasterPort       int           // master_port
	MasterLinkStatus string        // master_link_status
	MasterLastIO     time.Duration // master_last_io_seconds_ago

	MasterSyncInProgress bool          // master_sync_in_progress
	MasterSyncLeftBytes  int64         // master_sync_left_bytes
	MasterSyncLastIO     time.Duration // master_sync_last_io_seconds_ago
	MasterLinkDownSince  time.Duration // master_link_down_since_seconds

	ConnectedSlaves int      // connected_slaves
	Slaves          []string // slaveXXX
}

RedisInfo represents the reply from an INFO command. Not all fields are listed.

func ParseRedisInfo

func ParseRedisInfo(s string) (*RedisInfo, error)

ParseRedisInfo parses the response from an INFO command.

type Status

type Status struct {
	Process *ProcessInfo `json:"process"`
}

Status represents response to the /status endpoint.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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