userver: storages::redis::DynamicRedis Class Reference
Loading...
Searching...
No Matches
storages::redis::DynamicRedis Class Reference

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

Detailed Description

Manages dynamically created Redis clients.

Definition at line 59 of file dynamic_redis.hpp.

Public Member Functions

void Init (std::shared_ptr< impl::ThreadPools > thread_pools, testsuite::RedisControl testsuite_redis_control)
bool AddClient (const std::string &name, const DynamicSettings &settings, dynamic_config::Source &config)
 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< ClientGetDynamicClient (const std::string &name, storages::redis::RedisWaitConnected wait_connected={}) const
 Retrieves a dynamically added client by name.
std::unordered_set< std::string > ListClients () const
 Lists the names of all dynamically added clients.
void WriteStatistics (utils::statistics::Writer &writer, const MetricsSettings &settings) const
 Writes statistics for all dynamic clients.
void OnConfigUpdate (const dynamic_config::Snapshot &cfg)

Member Function Documentation

◆ AddClient()

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

Adds a new client with the specified name and settings.

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

◆ GetDynamicClient()

utils::SharedRef< Client > storages::redis::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 pointer to the client throws std::out_of_range exception if there is no client with requested name

◆ ListClients()

std::unordered_set< std::string > storages::redis::DynamicRedis::ListClients ( ) const

Lists the names of all dynamically added clients.

Returns
a set of client names

◆ RemoveClient()

bool storages::redis::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

◆ WriteStatistics()

void storages::redis::DynamicRedis::WriteStatistics ( utils::statistics::Writer & writer,
const MetricsSettings & settings ) const

Writes statistics for all dynamic clients.

Parameters
writerstatistics writer
settingsmetrics settings

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