Documentation
¶
Overview ¶
Package valkeyclient provides a lightweight Valkey/Redis RESP protocol client for health checking and replication monitoring.
Index ¶
- type Client
- func (c *Client) DBSize() (int, error)
- func (c *Client) InfoReplication() (*ReplicationInfo, error)
- func (c *Client) Ping() error
- func (c *Client) ReplicaOf(host, port string) error
- func (c *Client) SentinelFailover(name string) error
- func (c *Client) SentinelMaster(name string) (*SentinelMasterInfo, error)
- func (c *Client) SentinelMonitorAdd(name, ip string, port, quorum int) error
- func (c *Client) SentinelRemove(name string) error
- func (c *Client) SentinelReset(pattern string) error
- func (c *Client) SentinelSet(name, option, value string) error
- func (c *Client) Wait(numReplicas int, timeoutMs int) (int, error)
- type ConnectionError
- type ReplicationInfo
- type SentinelMasterInfo
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 NewTLS ¶ added in v1.0.1
NewTLS creates a new Valkey client that connects using TLS. The tlsConfig must contain at least the CA certificate for server verification.
func NewTLSWithPassword ¶ added in v1.1.0
NewTLSWithPassword creates a TLS Valkey client with password authentication.
func NewWithPassword ¶ added in v1.1.0
NewWithPassword creates a new Valkey client with password authentication. The AUTH command is sent automatically on each connection.
func (*Client) DBSize ¶
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) ReplicaOf ¶ added in v1.1.0
ReplicaOf sends REPLICAOF <host> <port> to reconfigure a node as a replica of the given master. This is used to fix cascaded replication chains where a replica points to an intermediate node instead of the actual master.
func (*Client) SentinelFailover ¶
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 ¶
SentinelMonitorAdd sends SENTINEL MONITOR <name> <ip> <port> <quorum> to add a new master to sentinel monitoring.
func (*Client) SentinelRemove ¶
SentinelRemove sends SENTINEL REMOVE <name> to remove a monitored master and all its associated replicas and sentinels from sentinel's tracking.
func (*Client) SentinelReset ¶
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 ¶
SentinelSet sends SENTINEL SET <name> <option> <value> to change a sentinel configuration parameter for a monitored master.
type ConnectionError ¶ added in v1.1.2
type ConnectionError struct {
// Addr is the host:port that was dialled.
Addr string
// Cause is the underlying network error.
Cause error
// Hint is a short, human-readable explanation of the probable cause and
// how to resolve it (e.g. "check firewall rules").
Hint string
}
ConnectionError is returned whenever a TCP connection to a Valkey or Sentinel instance cannot be established. It always carries the target address and an actionable hint so that administrators can quickly identify firewall rules or NetworkPolicy misconfigurations that block access.
func (*ConnectionError) Error ¶ added in v1.1.2
func (e *ConnectionError) Error() string
func (*ConnectionError) Unwrap ¶ added in v1.1.2
func (e *ConnectionError) Unwrap() error
Unwrap preserves the full error chain so errors.Is / errors.As still work.