Skip to main content

RedisOptions

This class, RedisOptions, is a copy of redis.Options designed for use in configuration files. It provides a comprehensive set of fields to configure various aspects of a Redis client connection, including network settings, authentication, timeouts, and connection pooling parameters. It allows for detailed control over how the application connects and interacts with a Redis server.

Attributes

AttributeTypeDescription
Networkstring = tcpThe network type, either tcp or unix, used for connecting to Redis.
AddrstringThe host:port address of the Redis server.
ClientNamestringThe client name that will be set for each connection using the CLIENT SETNAME command.
Protocolint = 3The RESP protocol version (2 or 3) to negotiate with the Redis server.
UsernamestringThe username used to authenticate the connection with a Redis 6.0+ instance using the ACL system.
PasswordstringThe optional password for authentication, matching the server's requirepass or User Password for Redis 6.0+ ACL.
PasswordSecretNamestringThe name of the secret that contains the password for Redis authentication.
DBintThe database to be selected after connecting to the Redis server.
MaxRetriesint = 3The maximum number of retries before giving up on a failed operation; -1 disables retries.
MinRetryBackoffconfig.Duration = 8 millisecondsThe minimum backoff duration between each retry attempt; -1 disables backoff.
MaxRetryBackoffconfig.Duration = 512 millisecondsThe maximum backoff duration between each retry attempt; -1 disables backoff.
DialTimeoutconfig.Duration = 5 secondsThe timeout duration for establishing new connections to the Redis server.
ReadTimeoutconfig.Duration = 3 secondsThe timeout duration for socket reads; 0 uses default, -1 blocks indefinitely, -2 disables SetReadDeadline calls.
WriteTimeoutconfig.Duration = 3 secondsThe timeout duration for socket writes; 0 uses default, -1 blocks indefinitely, -2 disables SetWriteDeadline calls.
ContextTimeoutEnabledboolA boolean indicating whether the client respects context timeouts and deadlines for operations.
PoolFIFOboolA boolean indicating the type of connection pool; true for FIFO, false for LIFO.
PoolSizeint = 10 connections per CPUThe base number of socket connections in the pool, with new connections allocated in excess if needed.
PoolTimeoutconfig.Duration = ReadTimeout + 1 secondThe amount of time the client waits for a connection if all connections are busy before returning an error.
MinIdleConnsint = 0The minimum number of idle connections to maintain in the pool.
MaxIdleConnsint = 0The maximum number of idle connections to maintain in the pool.
MaxActiveConnsintThe maximum number of connections allocated by the pool at a given time; zero means no limit.
ConnMaxIdleTimeconfig.Duration = 30 minutesThe maximum amount of time a connection may be idle before being closed; < = 0 disables idle timeout.
ConnMaxLifetimeconfig.Duration = not close idle connectionsThe maximum amount of time a connection may be reused before being closed; < = 0 disables lifetime limit.
TLSConfig*tls.ConfigThe TLS configuration to use for negotiating TLS, which is not settable from a config file.
UseTLSboolA boolean indicating whether to negotiate TLS using the system certificate pool, ignored if TLSConfig is provided.
TLSInsecureSkipVerifyboolA boolean that disables server certificate verification, intended only for testing against self-signed certificates.
DisableIndentitybool = falseA boolean that disables the set-lib command on connection.

Methods


GetOptions()

@classmethod
def GetOptions(
ctx: context.Context,
secretManager: [SecretManager](../../flyteplugins/go/tasks/pluginmachinery/core/secretmanager.md?sid=flyteplugins_go_tasks_pluginmachinery_core_secretmanager)
) - > (*redis.Options, error)

Retrieves Redis options, potentially fetching the password from a secret manager if PasswordSecretName is specified. This method is used to construct the redis.Options object required for connecting to a Redis instance.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for cancellation and timeouts.
secretManager[SecretManager](../../flyteplugins/go/tasks/pluginmachinery/core/secretmanager.md?sid=flyteplugins_go_tasks_pluginmachinery_core_secretmanager)The secret manager instance used to retrieve the Redis password if PasswordSecretName is set.

Returns

TypeDescription
(*redis.Options, error)A pointer to the redis.Options struct configured for connection, and an error if any occurred during secret retrieval or option processing.