#include <userver/storages/redis/component.hpp>
Redis client component.
Provides access to a redis cluster.
Name | Description | Default value |
---|---|---|
thread_pools.redis_thread_pool_size | thread count to serve Redis requests | - |
thread_pools.sentinel_thread_pool_size | thread count to serve sentinel requests. | - |
groups | array of redis clusters to work with excluding subscribers | - |
groups.[].config_name | key name in secdist with options for this cluster | - |
groups.[].db | name to refer to the cluster in components::Redis::GetClient() | - |
groups.[].sharding_strategy | one of RedisCluster, KeyShardCrc32, KeyShardTaximeterCrc32 or KeyShardGpsStorageDriver | "KeyShardTaximeterCrc32" |
groups.[].allow_reads_from_master | allows read requests from master instance | false |
subscribe_groups | array of redis clusters to work with in subscribe mode | - |
subscribe_groups.[].config_name | key name in secdist with options for this cluster | - |
subscribe_groups.[].db | name to refer to the cluster in components::Redis::GetSubscribeClient() | - |
subscribe_groups.[].sharding_strategy | either RedisCluster or KeyShardTaximeterCrc32 | "KeyShardTaximeterCrc32" |
If a config_name
option is provided, for example groups.some.config_name: some_name_of_your_database
, then the Secdist entry for that alias should look like following:
Redis cluster is the new recommended way of setting up Redis servers with improved stability.
To start, set sharding_strategy: RedisCluster
in the static config as shown above.
Secdist configuration is simplified:
"shards"
field is ignored, you can specify an empty array there;"sentinels"
field should contain some of the cluster nodes. They are only used for topology discovery; it is not necessary to list all nodes. Definition at line 127 of file component.hpp.
Public Member Functions | |
Redis (const ComponentConfig &config, const ComponentContext &component_context) | |
std::shared_ptr< storages::redis::Client > | GetClient (const std::string &name, ::redis::RedisWaitConnected wait_connected={}) const |
std::shared_ptr< redis::Sentinel > | Client (const std::string &name) const |
std::shared_ptr< storages::redis::SubscribeClient > | GetSubscribeClient (const std::string &name, ::redis::RedisWaitConnected wait_connected={}) const |
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 = "redis" |
The default name of components::Redis. | |
Protected Types | |
using | LoggableComponentBase = ComponentBase |
Legacy alias, use ComponentBase instead. | |
|
protectedinherited |
Legacy alias, use ComponentBase instead.
Definition at line 67 of file component_base.hpp.
|
inlineoverridevirtualinherited |
Override this function to inform the world of the state of your component.
Reimplemented from components::RawComponentBase.
Reimplemented in server::handlers::Restart.
Definition at line 35 of file component_base.hpp.
|
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 urabbitmq::ConsumerComponentBase, and components::Server.
Definition at line 58 of file component_base.hpp.
|
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 urabbitmq::ConsumerComponentBase, components::Server, and server::handlers::Ping.
Definition at line 51 of file component_base.hpp.
|
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.