redisutil

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package redisutil centralizes Redis address parsing for every parsec surface that takes an address as a string: the library's Options.RedisAddr, the `parsec keys` subcommands, and parsec-keys-sync.

It exists because go-redis' Options.Addr is a bare host:port while the broker (centrifuge.RedisShardConfig.Address) accepts full URLs. Parsec documents the URL forms, so every string-to-client conversion has to parse them the same way — previously each caller stripped the scheme by hand, which quietly discarded credentials, the database number, and (for rediss://) TLS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientOptions

func ClientOptions(addr string, auth Auth) (*redis.Options, error)

ClientOptions converts addr plus auth into go-redis options.

Accepted address forms:

host:port
redis://[[user][:password]@]host:port[/db][?opt=val]
rediss://...  (same, TLS)
tcp://...     (alias for redis://)
unix://[[user][:password]@]/path/to/socket[?db=n]

Sentinel and cluster URLs are rejected with a message pointing at Options.RedisClient, which takes a fully-configured client.

func NewClient

func NewClient(addr string, auth Auth) (*redis.Client, error)

NewClient builds a client from addr plus auth. The client is lazy — nothing is dialed until the first command — so callers that need fail-fast behavior should Ping it.

Types

type Auth

type Auth struct {
	Username string
	Password string
	// DB selects the logical database. Nil means "not set", so a
	// deliberate 0 still overrides a URL-supplied database.
	DB *int
	// TLS, when non-nil, forces a TLS connection with this config. Use it
	// for private CAs; rediss:// addresses get a default config without it.
	TLS *tls.Config
}

Auth carries the credential and transport overrides an operator can supply alongside the address. Every field is optional; a set field wins over whatever the address encoded, so a password in the config file overrides one embedded in the URL.

Jump to

Keyboard shortcuts

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