clusterinfo

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

chunks.go provides a base parser that loads rladmin output and parses it into chunks for each section. Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

databases.go provides a parser for the database information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

endpoints.go provides a parser for the node information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

nodes.go provides a parser for the node information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

shards.go provides a parser for the shard information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

Index

Constants

View Source
const (
	ChunkNone = iota
	ChunkCluster
	ChunkNodes
	ChunkDatabases
	ChunkEndpoints
	ChunkShards
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunks

type Chunks struct {
	Intro     string
	Nodes     []byte
	Databases []byte
	Endpoints []byte
	Shards    []byte
}

Chunks is used to store the output of the base parser.

func (*Chunks) ExtractTimeStamp

func (c *Chunks) ExtractTimeStamp() (time.Time, error)

ExtractTimeStamp finds the timestamp at the start of the output and returns it as time.Time

func (*Chunks) Parse

func (c *Chunks) Parse(input io.Reader) error

func (*Chunks) ParseDatabases

func (c *Chunks) ParseDatabases(parent *ClusterInfo) (Databases, error)

func (*Chunks) ParseEndpoints

func (c *Chunks) ParseEndpoints(parent *ClusterInfo) (Endpoints, error)

func (*Chunks) ParseNodes

func (c *Chunks) ParseNodes(parent *ClusterInfo) (Nodes, error)

func (*Chunks) ParseShards

func (c *Chunks) ParseShards(parent *ClusterInfo) (Shards, error)

type ClusterInfo

type ClusterInfo struct {
	Unparsed  *Chunks   `json:"-"`
	Databases Databases `json:"databases"`
	Endpoints Endpoints `json:"endpoints"`
	Shards    Shards    `json:"shards"`
	Nodes     Nodes     `json:"nodes"`
	TimeStamp time.Time `json:"timeSteamp"`
}

ClusterInfo represents all the data loaded from the rladmin status output

func NewClusterInfo

func NewClusterInfo(in io.Reader) (*ClusterInfo, error)

func (*ClusterInfo) DatabasesWithNodes

func (c *ClusterInfo) DatabasesWithNodes() DatabasesWithNodes

func (*ClusterInfo) JSON

func (c *ClusterInfo) JSON() (string, error)

type DBEndPoints

type DBEndPoints []string

func (*DBEndPoints) MarshalCSV

func (e *DBEndPoints) MarshalCSV() (string, error)

func (*DBEndPoints) UnmarshalCSV

func (e *DBEndPoints) UnmarshalCSV(input string) error

type DBNodes

type DBNodes map[string]*DBShards

func (*DBNodes) MarshalCSV

func (n *DBNodes) MarshalCSV() (string, error)

type DBShards

type DBShards struct {
	Masters  uint16
	Replicas uint16
}

type Database

type Database struct {
	Id                string      `csv:"DB:ID" json:"id"`
	Name              string      `csv:"NAME" json:"name"`
	Type              string      `csv:"TYPE" json:"type"`
	Status            string      `csv:"STATUS" json:"status"`
	MasterShards      uint16      `csv:"SHARDS" json:"shards"`
	Placement         string      `csv:"PLACEMENT" json:"placement"`
	Replication       string      `csv:"REPLICATION" json:"replication"`
	Persistence       string      `csv:"PERSISTENCE" json:"persistence"`
	Endpoint          DBEndPoints `csv:"ENDPOINT" json:"endpoints"`
	ExecState         string      `csv:"EXEC_STATE" json:"execState"`
	ExecStateMachine  string      `csv:"EXEC_STATE_MACHINE" json:"execStateMachine"`
	BackupProgress    string      `csv:"BACKUP_PROGRESS" json:"backupProgress"`
	MissingBackupTime string      `csv:"MISSING_BACKUP_TIME" json:"missingBackupTime"`
	RedisVersion      string      `csv:"REDIS_VERSION" json:"redisVersion"`
	// contains filtered or unexported fields
}

func (*Database) JSON

func (db *Database) JSON() (string, error)

JSON returns the database struct marsalled to JSON

func (*Database) OnNode

func (db *Database) OnNode(id string) DBShards

OnNode returns the number of shards on the given node for a database.

func (*Database) ShardCount

func (d *Database) ShardCount() uint16

ShardCount returns the total number of shards by counting them.

type DatabaseWithNodes

type DatabaseWithNodes struct {
	Database
	Nodes DBNodes `json:"nodes" csv:"NODES"`
}

type Databases

type Databases []*Database

func (Databases) CSV

func (d Databases) CSV() (string, error)

func (*Databases) JSON

func (d *Databases) JSON() (string, error)

type DatabasesWithNodes

type DatabasesWithNodes []*DatabaseWithNodes

func (DatabasesWithNodes) CSV

func (d DatabasesWithNodes) CSV() (string, error)

func (DatabasesWithNodes) JSON

func (d DatabasesWithNodes) JSON() (string, error)

type Endpoint

type Endpoint struct {
	Id             string `json:"id" csv:"ID"`
	DBId           string `json:"dbId" csv:"DB:ID"`
	Name           string `json:"name" csv:"NAME"`
	Node           string `json:"node" csv:"NODE"`
	Role           string `json:"role" csv:"ROLE"`
	SSL            bool   `json:"ssl" csv:"SSL"`
	WatchdogStatus string `json:"watchdogStatus" csv:"WATCHDOG_STATUS"`
	// contains filtered or unexported fields
}

type Endpoints

type Endpoints []*Endpoint

func (Endpoints) CSV

func (e Endpoints) CSV() (string, error)

func (Endpoints) JSON

func (e Endpoints) JSON() (string, error)

type IP

type IP struct {
	net.IP
}

func (*IP) UnmarshalCSV

func (i *IP) UnmarshalCSV(input string) error

type MemoryInfo

type MemoryInfo struct {
	Free RAMFloat `json:"free"`
	Max  RAMFloat `json:"max"`
}

func (*MemoryInfo) UnmarshalCSV

func (m *MemoryInfo) UnmarshalCSV(input string) error

type Node

type Node struct {
	Id               string     `json:"id" csv:"NODE:ID"`
	Role             string     `json:"role" csv:"ROLE"`
	Address          IP         `json:"address" csv:"ADDRESS"`
	ExternalAddress  IP         `json:"externalAddress" csv:"EXTERNAL_ADDRESS"`
	HostName         string     `json:"hostName" csv:"HOSTNAME"`
	OverbookingDepth RAMFloat   `json:"overbookingDepth" csv:"OVERBOOKING_DEPTH"`
	Masters          uint16     `json:"masters" csv:"MASTERS"`
	Replicas         uint16     `json:"replicas" csv:"SLAVES"`
	ShardUsage       ShardInfo  `json:"shards" csv:"SHARDS"`
	Cores            uint16     `json:"cores" csv:"CORES"`
	RedisRAM         MemoryInfo `json:"redisRAM" csv:"FREE_RAM"`
	ProvisionalRAM   MemoryInfo `json:"provisionalRAM" csv:"PROVISIONAL_RAM"`
	Version          string     `json:"version" csv:"VERSION"`
	SHA              string     `json:"sha" csv:"SHA"`
	RackId           string     `json:"rackId" csv:"RACK-ID"`
	Status           string     `json:"status" csv:"STATUS"`
	Quorum           bool       `json:"quorum" csv:"-"`
	// contains filtered or unexported fields
}

type Nodes

type Nodes []*Node

func (Nodes) CSV

func (ns Nodes) CSV() (string, error)

func (Nodes) JSON

func (ns Nodes) JSON() (string, error)

type RAMFloat

type RAMFloat float64

func (*RAMFloat) MarshalCSV

func (g *RAMFloat) MarshalCSV() (string, error)

func (*RAMFloat) MarshalJSON

func (g *RAMFloat) MarshalJSON() ([]byte, error)

func (*RAMFloat) UnmarshalCSV

func (g *RAMFloat) UnmarshalCSV(s string) error

type Serializer

type Serializer interface {
	CSV() (string, error)
	JSON() (string, error)
}

type Shard

type Shard struct {
	Id             string   `json:"id" csv:"ID"`
	DBId           string   `json:"dbId" csv:"DB:ID"`
	Name           string   `json:"name" csv:"NAME"`
	Node           string   `json:"node" csv:"NODE"`
	Role           string   `json:"role" csv:"ROLE"`
	Slots          string   `json:"slots" csv:"SLOTS"`
	UsedMemory     RAMFloat `json:"usedMemory" csv:"USED_MEMORY"`
	BackupProgress string   `json:"backupProgress" csv:"BACKUP_PROGRESS"`
	RAMFrag        RAMFloat `json:"ramFrag" csv:"RAM_FRAG"`
	WatchdogStatus string   `json:"watchdogStatus" csv:"WATCHDOG_STATUS"`
	Status         string   `json:"status" csv:"STATUS"`
	// contains filtered or unexported fields
}

type ShardInfo

type ShardInfo struct {
	InUse uint16 `json:"shardsInUse"`
	Max   uint16 `json:"maxShards"`
}

func (*ShardInfo) UnmarshalCSV

func (s *ShardInfo) UnmarshalCSV(input string) error

type Shards

type Shards []*Shard

func (Shards) CSV

func (s Shards) CSV() (string, error)

func (Shards) ForDB

func (s Shards) ForDB(id string) Shards

ForDB returns all the shards for a given database, sorted in Id order

func (Shards) JSON

func (s Shards) JSON() (string, error)

Jump to

Keyboard shortcuts

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