userver: components::DynamicRedis Class Reference
Loading...
Searching...
No Matches
components::DynamicRedis Class Reference

#include <userver/storages/redis/dynamic_component.hpp>

Detailed Description

Valkey and Redis dynamic client component, that does not require secdist.

Provides access to a valkey or redis cluster.

Dynamic options:

Same as for components::Redis

Static options of components::Redis :

Name Description Default value
thread_pools Thread pools options.
thread_pools.redis_thread_pool_size Thread count to serve Redis requests.
thread_pools.sentinel_thread_pool_size Thread count to serve sentinel requests.
metrics_level Set metrics detail level. Possible values: cluster, shard, instance. instance

Options inherited from components::ComponentBase :

Name Description Default value
load-enabled Set to false to disable loading of the component. true

Definition at line 56 of file dynamic_component.hpp.

+ Inheritance diagram for components::DynamicRedis:

Public Member Functions

 DynamicRedis (const ComponentConfig &config, const ComponentContext &component_context)
 
bool AddClient (const std::string &name, const storages::redis::DynamicSettings &settings)
 Adds a new client with the specified name and settings.
 
bool RemoveClient (const std::string &name)
 Removes a client with the specified name.
 
utils::SharedRef< storages::redis::ClientGetDynamicClient (const std::string &name, storages::redis::RedisWaitConnected wait_connected={}) const
 Retrieves a dynamically added client by name.
 
std::unordered_set< std::string > ListDynamicClients () const
 Lists the names of all dynamically added clients.
 
ComponentHealth GetComponentHealth () const override
 
void OnLoadingCancelled () override
 
void OnAllComponentsLoaded () override
 
void OnAllComponentsAreStopping () override
 

Static Public Member Functions

static yaml_config::Schema GetStaticConfigSchema ()
 

Static Public Attributes

static constexpr std::string_view kName = "dynamic-redis"
 The default name of components::DynamicRedis.
 

Protected Types

using LoggableComponentBase = ComponentBase
 

Member Typedef Documentation

◆ LoggableComponentBase

Member Function Documentation

◆ AddClient()

bool components::DynamicRedis::AddClient ( const std::string & name,
const storages::redis::DynamicSettings & settings )

Adds a new client with the specified name and settings.

Parameters
namethe name of the client
settingsthe dynamic settings for the client
Returns
true if the client was added, false if a client with the same name already exists

◆ GetComponentHealth()

ComponentHealth components::ComponentBase::GetComponentHealth ( ) const
inlineoverridevirtualinherited

Override this function to inform the world of the state of your component.

Warning
The function is called concurrently from multiple threads.

Reimplemented from components::RawComponentBase.

Reimplemented in server::handlers::Restart.

Definition at line 35 of file component_base.hpp.

◆ GetDynamicClient()

utils::SharedRef< storages::redis::Client > components::DynamicRedis::GetDynamicClient ( const std::string & name,
storages::redis::RedisWaitConnected wait_connected = {} ) const

Retrieves a dynamically added client by name.

Parameters
namethe name of the client
wait_connectedwait mode for the client connection
Returns
shared reference to the client or throws out_of_range exception if not found

◆ ListDynamicClients()

std::unordered_set< std::string > components::DynamicRedis::ListDynamicClients ( ) const

Lists the names of all dynamically added clients.

Returns
a set of client names

◆ OnAllComponentsAreStopping()

void components::ComponentBase::OnAllComponentsAreStopping ( )
inlineoverridevirtualinherited

Component may use this function to stop doing work before the stop of the components that depend on it.

Base components may override it and make final to do some work before the derived object constructor is called. Don't use it otherwise.

Reimplemented from components::RawComponentBase.

Reimplemented in components::Server, and urabbitmq::ConsumerComponentBase.

Definition at line 58 of file component_base.hpp.

◆ OnAllComponentsLoaded()

void components::ComponentBase::OnAllComponentsLoaded ( )
inlineoverridevirtualinherited

Component may use this function to finalize registration of other components that depend on it (for example, handler components register in server component, and the latter uses OnAllComponentsLoaded() to start processing requests).

Base components may override it and make final to do some work after the derived object constructor is called. Don't use it otherwise.

Reimplemented from components::RawComponentBase.

Reimplemented in components::Server, server::handlers::Ping, and urabbitmq::ConsumerComponentBase.

Definition at line 51 of file component_base.hpp.

◆ OnLoadingCancelled()

void components::ComponentBase::OnLoadingCancelled ( )
inlineoverridevirtualinherited

Called once if the creation of any other component failed. If the current component expects some other component to take any action with the current component, this call is a signal that such action may never happen due to components loading was cancelled. Application components might not want to override it.

Reimplemented from components::RawComponentBase.

Definition at line 42 of file component_base.hpp.

◆ RemoveClient()

bool components::DynamicRedis::RemoveClient ( const std::string & name)

Removes a client with the specified name.

Parameters
namethe name of the client to remove
Returns
true if the client was removed, false if no client with the specified name exists

The documentation for this class was generated from the following file: