valkeyclient

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package valkeyclient provides a lightweight Valkey/Redis RESP protocol client for health checking and replication monitoring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a minimal Valkey/Redis client using raw RESP protocol. It does not depend on any external Redis Go client library.

func New

func New(addr string) *Client

New creates a new Valkey client for the given address (host:port).

func NewTLS added in v1.0.1

func NewTLS(addr string, tlsConfig *tls.Config) *Client

NewTLS creates a new Valkey client that connects using TLS. The tlsConfig must contain at least the CA certificate for server verification.

func (*Client) DBSize

func (c *Client) DBSize() (int, error)

DBSize sends the DBSIZE command and returns the number of keys in the current database.

func (*Client) InfoReplication

func (c *Client) InfoReplication() (*ReplicationInfo, error)

InfoReplication sends INFO replication and parses the result.

func (*Client) Ping

func (c *Client) Ping() error

Ping sends a PING command and returns nil if the response is PONG.

func (*Client) SentinelFailover

func (c *Client) SentinelFailover(name string) error

SentinelFailover sends SENTINEL FAILOVER <name> to trigger a manual failover.

func (*Client) SentinelMaster

func (c *Client) SentinelMaster(name string) (*SentinelMasterInfo, error)

SentinelMaster sends SENTINEL MASTER <name> and parses the result.

func (*Client) SentinelMonitorAdd

func (c *Client) SentinelMonitorAdd(name, ip string, port, quorum int) error

SentinelMonitorAdd sends SENTINEL MONITOR <name> <ip> <port> <quorum> to add a new master to sentinel monitoring.

func (*Client) SentinelRemove

func (c *Client) SentinelRemove(name string) error

SentinelRemove sends SENTINEL REMOVE <name> to remove a monitored master and all its associated replicas and sentinels from sentinel's tracking.

func (*Client) SentinelReset

func (c *Client) SentinelReset(pattern string) error

SentinelReset sends SENTINEL RESET <pattern> to reset all matching masters. This clears the sentinel's internal failover cooldown state, allowing a new failover to be triggered immediately. The pattern "*" matches all masters.

func (*Client) SentinelSet

func (c *Client) SentinelSet(name, option, value string) error

SentinelSet sends SENTINEL SET <name> <option> <value> to change a sentinel configuration parameter for a monitored master.

func (*Client) Wait

func (c *Client) Wait(numReplicas int, timeoutMs int) (int, error)

Wait sends the WAIT command to block until all the previous write commands are acknowledged by at least numReplicas replicas, or until the timeout (in milliseconds) expires. It returns the number of replicas that acknowledged.

type ReplicationInfo

type ReplicationInfo struct {
	Role                 string
	ConnectedSlaves      int
	MasterHost           string
	MasterPort           string
	MasterLinkStatus     string
	MasterSyncInProgress bool
}

ReplicationInfo holds parsed INFO replication output.

type SentinelMasterInfo

type SentinelMasterInfo struct {
	Name      string
	IP        string
	Port      string
	NumSlaves int
	Quorum    int
	Flags     string
}

SentinelMasterInfo holds parsed SENTINEL MASTER output.

Jump to

Keyboard shortcuts

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