connection

package
v1.3.3-0...-f31c912 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// URIScheme is a Redis scheme: https://www.iana.org/assignments/uri-schemes/prov/redis
	// Teleport always uses Redis connection over TLS.
	URIScheme = "redis"
	// URISchemeTLS is a Redis scheme that uses TLS for database connection: https://www.iana.org/assignments/uri-schemes/prov/rediss
	URISchemeTLS = "rediss"
)
View Source
const DefaultPort = "6379"

DefaultPort is the Redis default port.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mode

type Mode string

Mode defines the mode in which Redis is configured. Currently, supported are single and cluster.

const (
	// Standalone mode should be used when connecting to a single Redis instance.
	Standalone Mode = "standalone"
	// Cluster mode should be used when connecting to a Redis Cluster.
	Cluster Mode = "cluster"
)

type Options

type Options struct {
	// Mode defines Redis connection mode like cluster or single instance.
	Mode Mode
	// address of Redis instance.
	Address string
	// port on which Redis expects new connections.
	Port string
}

Options defines Redis connection options.

func ParseRedisAddress

func ParseRedisAddress(addr string) (*Options, error)

ParseRedisAddress parses a Redis connection string and returns the parsed connection options like address and connection mode. If port is skipped default Redis 6379 is used. Correct inputs:

rediss://redis.example.com:6379?mode=cluster
redis://redis.example.com:6379
redis.example.com:6379

Incorrect input:

redis.example.com:6379?mode=cluster

func ParseRedisAddressWithDefaultMode

func ParseRedisAddressWithDefaultMode(addr string, defaultMode Mode) (*Options, error)

ParseRedisAddressWithDefaultMode parses a Redis connection string and uses the provided default mode if mode is not specified in the address.

Jump to

Keyboard shortcuts

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