Documentation ¶
Overview ¶
Package structures provides common and useful structures for interacting with Redis
Index ¶
- type AllInfoConfig
- type ClusterNode
- type ClusterSlot
- type CommandEntry
- type InfoCPU
- type InfoClients
- type InfoCluster
- type InfoCommandStats
- type InfoKeyspace
- type InfoMemory
- type InfoPersistence
- type InfoReplication
- type InfoServer
- type InfoSlaves
- type InfoStats
- type MasterAddress
- type MasterInfo
- type RedisInfoAll
- type Sentinel
- type SentinelInfo
- type SentinelList
- type SlaveInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllInfoConfig ¶
type AllInfoConfig struct { Input map[string]map[string]string Info RedisInfoAll }
AllInfoConfig is used to contain the RedisInfoAll struct and the data parsed from the info command
type ClusterNode ¶
type ClusterNode struct { Id string Address string Flags []string Master string PingSent int64 PongRecv int64 ConfigEpoch int LinkStateUp bool Slots []ClusterSlot }
<id> <ip:port> <flags> <master> <ping-sent> <pong-recv> <config-epoch> <link-state> <slot> <slot> ... <slot>
type ClusterSlot ¶
type CommandEntry ¶
type CommandEntry struct { Name string Arity int64 Flags map[string]bool FirstKey int64 LastKey int64 RepeatCount int64 }
CommandEntry defines the entries for a Redis command as shown in the results of the COMMAND command.
func (*CommandEntry) Admin ¶
func (c *CommandEntry) Admin() bool
Admin returns true if the command has the "admin" flag set.
func (*CommandEntry) Pubsub ¶
func (c *CommandEntry) Pubsub() bool
Pubsub returns true if the command is pubsub related
func (*CommandEntry) ReadOnly ¶
func (c *CommandEntry) ReadOnly() bool
ReadOnly returns true if the command has the "readonly" flag set.
func (*CommandEntry) Writes ¶
func (c *CommandEntry) Writes() bool
Writes returns true if the command has the "write" flag set. This indicates modifications are made to the datastore
type InfoCPU ¶
type InfoCPU struct { UsedCPUSystem float64 `redis:"used_cpu_sys"` UsedCPUUser float64 `redis:"used_cpu_user"` UsedCPUChildren float64 `redis:"used_cpu_sys_children"` UsedCPUUserChildren float64 `redis:"used_cpu_user_children"` }
InfoCPU represents the CPU section of Redis INFO
type InfoClients ¶
type InfoClients struct { ConnectedClients int `redis:"connected_clients"` ClientLongestOutputList int `redis:"client_longest_output_list"` ClientBiggestInputBuffer int `redis:"client_biggest_input_buf"` BlockedClients int `redis:"blocked_clients"` }
InfoClients represents the Client section of Redis INFO
type InfoCluster ¶
type InfoCluster struct {
Enabled bool
}
InfoCluster is a struct representing the Cluster section of Redis Info
type InfoCommandStats ¶
InfoCommandStats represents the CommandStats section of Redis INFO
type InfoKeyspace ¶
InfoKeyspace represents the Keyspace section of Redis INFO
type InfoMemory ¶
type InfoMemory struct { UsedMemory int `redis:"used_memory"` UsedMemoryHuman string `redis:"used_memory_human"` UsedMemoryRss int `redis:"used_memory_rss"` UsedMemoryPeak int `redis:"used_memory_peak"` UsedMemoryPeakHuman string `redis:"used_memory_peak_human"` TotalSystemMemory int `redis:"total_system_memory"` TotalSystemMemoryHuman string `redis:"total_system_memory_human"` UsedMemoryLua int `redis:"used_memory_lua"` UsedMemoryLuaHuman int `redis:"used_memory_lua_human"` MaxMemory int `redis:"maxmemory"` MaxMemoryHuman int `redis:"maxmemory_human"` MaxMemoryPolicy int `redis:"maxmemory_policy"` MemoryFragmentationRatio float64 `redis:"mem_fragmentation_ratio"` MemoryAllocator string `redis:"mem_allocator"` }
InfoMemory is the struct returning the memory section for Redis Info
type InfoPersistence ¶
type InfoPersistence struct { Loading bool `redis:"loading"` ChangesSinceSave int `redis:"rdb_changes_since_last_save"` BGSavesInProgress bool `redis:"rdb_bgsave_in_progress"` LastSaveTime uint `redis:"rdb_last_save_time"` LastBGSaveStatus string `redis:"rdb_last_bgsave_status"` LastBGSaveTime uint `redis:"rdb_last_bgsave_time_sec"` CurrentBGSaveTime uint `redis:"rdb_current_bgsave_time_sec"` AOFEnabled bool `redis:"aof_enabled"` FRewriteInProgress bool `redis:"aof_rewrite_in_progress"` RewriteScheduled bool `redis:"aof_rewrite_scheduled"` LastRewriteTimeInSeconds int `redis:"aof_last_rewrite_time_sec"` CurrentRewriteTimeInSeconds int `redis:"aof_current_rewrite_time_sec"` LastBGRewriteStatus string `redis:"aof_last_bgrewrite_status"` LastAOFWriteSTats string `redis:"aof_last_write_status"` }
InfoPersistence reprsents the Perisstence section of Redis INFO
type InfoReplication ¶
type InfoReplication struct { Role string `redis:"role"` ConnectedSlaves int `redis:"connected_slaves"` MasterReplicationOffset int `redis:"master_repl_offset"` ReplicationBacklogActive int `redis:"repl_backlog_active"` ReplicationBacklogSize int `redis:"repl_backlog_size"` ReplicationBacklogFirstByte int `redis:"repl_backlog_first_byte_offset"` ReplicationBacklogHistLen int `redis:"repl_backlog_histlen"` MasterHost string `redis:"master_host"` MasterPort int `redis:"master_port"` MasterLinkStatus string `redis:"master_link_status"` MasterLastIOSecondsAgo int `redis:"master_last_io_seconds_ago"` MasterSyncInProgress bool `redis:"master_sync_in_progress"` SlaveReplicationOffset int `redis:"slave_repl_offset"` SlavePriority int `redis:"slave_priority"` SlaveReadOnly bool `redis:"slave_read_only"` Slaves []InfoSlaves `redis:"slave*"` }
InfoReplication represents the Replication section of Redis INFO
type InfoServer ¶
type InfoServer struct { Version string `redis:"redis_version"` Git_sha1 int `redis:"redis_git_sha1"` Git_dirty bool `redis:"redis_git_dirty"` RedisBuildId string `redis:"redis_build_id"` Mode string `redis:"redis_mode"` OS string `redis:"os"` Arch_bits int `redis:"arch_bits"` Multiplexing string `redis:"multiplexing_api"` GCC_version string `redis:"gcc_version"` ProcessId int `redis:"process_id"` TCPPort int `redis:"tcp_port"` UptimeInSeconds int `redis:"uptime_in_seconds"` UptimeInDays int `redis:"uptime_in_days"` Hz int `redis:"hz"` LRU_clock int `redis:"lru_clock"` Executable string `redis:"executable"` ConfigFile string `redis:"config_file"` }
InfoServer is a struct for the results returned from an 'INFO server' command
Currently the members defined by redis are as follows. redis_version redis_git_sha1 redis_git_dirty redis_build_id redis_mode os arch_bits multiplexing_api gcc_version process_id run_id tcp_port uptime_in_seconds uptime_in_days hz lru_clock config_file
type InfoSlaves ¶
InfoSlaves represents the slave identity in the replication section of the Redis INFO command
type InfoStats ¶
type InfoStats struct { TotalConnectionsReceived int `redis:"total_connections_received"` TotalCommandsProcessed int `redis:"total_commands_processed"` InstanteousOpsPerSecond int `redis:"instantaneous_ops_per_sec"` TotalNetInputBytes int `redis:"total_net_input_bytes"` TotalNetOutputBytes int `redis:"total_net_output_bytes"` InstanteousInputKbps float64 `redis:"instantaneous_input_kbps"` InstanteousOutputKbps float64 `redis:"instantaneous_output_kbps"` RejectedConnections int `redis:"rejected_connections"` SyncFull int `redis:"sync_full"` SyncPartialOk int `redis:"sync_partial_ok"` SyncPartialErr int `redis:"sync_partial_err"` ExpiredKeys int `redis:"expired_keys"` EvictedKeys int `redis:"evicted_keys"` KeyspaceHits int `redis:"keyspace_hits"` KeyspaceMisses int `redis:"keyspace_misses"` PubSubChannels int `redis:"pubsub_channels"` PubSubPatterns int `redis:"pubsub_patterns"` LatestForkUsec int `redis:"latest_fork_usec"` MigrateCachedSockets int `redis:"migrate_cached_sockets"` }
InfoStats represents the Stats section of Redis INFO
type MasterAddress ¶
MasterAddress is a small struct to provide connection information for a Master as returned from get-master-addr-by-name
type MasterInfo ¶
type MasterInfo struct { Name string `redis:"name"` Port int `redis:"port"` NumSlaves int `redis:"num-slaves"` Quorum int `redis:"quorum"` NumOtherSentinels int `redis:"num-other-sentinels"` ParallelSyncs int `redis:"parallel-syncs"` Runid string `redis:"runid"` IP string `redis:"ip"` DownAfterMilliseconds int `redis:"down-after-milliseconds"` IsMasterDown bool `redis:"is-master-down"` LastOkPingReply int `redis:"last-ok-ping-reply"` RoleReportedTime int `redis:"role-reported-time"` InfoRefresh int `redis:"info-refresh"` RoleReported string `redis:"role-reported"` LastPingReply int `redis:"last-ping-reply"` LastPingSent int `redis:"last-ping-sent"` FailoverTimeout int `redis:"failover-timeout"` ConfigEpoch int `redis:"config-epoch"` Flags string `redis:"flags"` }
MasterInfo is a struct providing the information available from sentinel about a given master (aka pod) The way this works is you tag the field with the name redis returns and reflect is used in the methods which return this structure to populate it with the data from Redis
Note this means it will nee dto be updated when new fields are added in sentinel. Fortunately this appears to be rare.
Currently the list is: 'pending-commands' 'ip' 'down-after-milliseconds' 'role-reported' 'runid' 'port' 'last-ok-ping-reply' 'last-ping-sent' 'failover-timeout' 'config-epoch' 'quorum' 'role-reported-time' 'last-ping-reply' 'name' 'parallel-syncs' 'info-refresh' 'flags' 'num-slaves' 'num-other-sentinels'
type RedisInfoAll ¶
type RedisInfoAll struct { Server InfoServer `section:"server"` CPU InfoCPU `section:"cpu"` Client InfoClients `section:"client"` Replication InfoReplication `section:"replication"` Memory InfoMemory `section:"memory"` Stats InfoStats `section:"stats"` Persistence InfoPersistence `section:"persistence"` Keyspace InfoKeyspace `section:"keyspace"` Commandstats InfoCommandStats `section:"commandstats"` }
RedisInfoAll is a struct containing structs for each redis section
type SentinelInfo ¶
type SentinelInfo struct { Name string `redis:"name"` IP string `redis:"ip"` Port int `redis:"port"` Runid string `redis:"runid"` Flags string `redis:"flags"` PendingCommands int `redis:"pending-commands"` LastPingReply int `redis:"last-ping-reply"` LastPingSent int `redis:"last-ping-sent"` LastOkPingReply int `redis:"last-ok-ping-reply"` DownAfterMilliseconds int `redis:"down-after-milliseconds"` LastHelloMessage int `redis:"last-hello-message"` VotedLeader string `redis:"voted-leader"` VotedLeaderEpoch int `redis:"voted-leader-epoch"` }
SentinelInfo represents the information returned from a "SENTINEL SENTINELS <name>" command
type SentinelList ¶
type SentinelList []Sentinel
type SlaveInfo ¶
type SlaveInfo struct { Name string `redis:"name"` Host string `redis:"ip"` Port int `redis:"port"` Runid string `redis:"runid"` Flags string `redis:"flags"` PendingCommands int `redis:"pending-commands"` IsMasterDown bool `redis:"is-master-down"` LastOkPingReply int `redis:"last-ok-ping-reply"` RoleReportedTime int `redis:"role-reported-time"` LastPingReply int `redis:"last-ping-reply"` LastPingSent int `redis:"last-ping-sent"` InfoRefresh int `redis:"info-refresh"` RoleReported string `redis:"role-reported"` MasterLinkDownTime int `redis:"master-link-down-time"` MasterLinkStatus string `redis:"master-link-status"` MasterHost string `redis:"master-host"` MasterPort int `redis:"master-port"` SlavePriority int `redis:"slave-priority"` SlaveReplicationOffset int `redis:"slave-repl-offset"` }
SlaveInfo is a struct for the results returned from slave queries, specifically the individual entries of the `sentinel slave <podname>` command. As with the other Sentinel structs this may change and will need updated for new entries Currently the members defined by sentinel are as follows. "name" "ip" "port" "runid" "flags" "pending-commands" "last-ping-sent" "last-ok-ping-reply" "last-ping-reply" "down-after-milliseconds" "info-refresh" "role-reported" "role-reported-time" "master-link-down-time" "master-link-status" "master-host" "master-port" "slave-priority" "slave-repl-offset"