userver: ydb::YdbComponent Class Reference
Loading...
Searching...
No Matches
ydb::YdbComponent Class Referencefinal

#include <userver/ydb/component.hpp>

Detailed Description

YDB client component.

Provides access to ydb::TableClient, ydb::TopicClient, ydb::FederatedTopicClient, ydb::CoordinationClient.

Static options of ydb::YdbComponent :

Name Description Default value
blocking_task_processor Deprecated, unused property.
credentials-provider Name of credentials provider component.
operation-settings Default operation settings for requests to the database.
operation-settings.retries Default retries count for an operation. 3
operation-settings.operation-timeout Default operation timeout in utils::StringToDuration() format. 1s
operation-settings.cancel-after Cancel operation after specified string in utils::StringToDuration() format. 1s
operation-settings.client-timeout Default client timeout in utils::StringToDuration format. 1s
operation-settings.get-session-timeout Default session timeout. 5s
databases.* Single database settings.
databases.*.endpoint GRPC endpoint URL, e.g. grpc://localhost:1234.
databases.*.database Full database path, e.g. /ru/service/production/database.
databases.*.credentials.* Credentials config passed to credentials provider component.
databases.*.max_pool_size Maximum connection pool size. 50
databases.*.min_pool_size Minimum connection pool size. 10
databases.*.get_session_retry_limit Retries count to get session, every attempt with a get-session-timeout. 5
databases.*.keep-in-query-cache Whether to use query cache. true
databases.*.prefer_local_dc Prefer making requests to local data center. true
databases.*.sync_start Fail to boot if YDB is not available. true
databases.*.aliases.[] List of aliases for this database. Each of the elements: alias name.
databases.*.by-database-timings-buckets-ms.[] Histogram bounds for by-database timing metrics. Each of the elements: upper bound for an individual bucket. 40 buckets with +20% increment per step
databases.*.by-query-timings-buckets-ms.[] Histogram bounds for by-query timing metrics. Each of the elements: upper bound for an individual bucket. 15 buckets with +100% increment per step

Options inherited from components::ComponentBase :

Name Description Default value
load-enabled Set to false to disable loading of the component. true
Examples
samples/ydb_service/components/federated_topic_reader.cpp, and samples/ydb_service/components/topic_reader.cpp.

Definition at line 40 of file component.hpp.

+ Inheritance diagram for ydb::YdbComponent:

Public Member Functions

 YdbComponent (const components::ComponentConfig &, const components::ComponentContext &)
 
std::shared_ptr< TableClientGetTableClient (const std::string &dbname) const
 
std::shared_ptr< TopicClientGetTopicClient (const std::string &dbname) const
 
std::shared_ptr< FederatedTopicClientGetFederatedTopicClient (const std::string &dbname) const
 
std::shared_ptr< CoordinationClientGetCoordinationClient (const std::string &dbname) const
 
const NYdb::TDriver & GetNativeDriver (const std::string &dbname) const
 
const std::string & GetDatabasePath (const std::string &dbname) 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 = "ydb"
 The default name of ydb::YdbComponent component.
 

Protected Types

using LoggableComponentBase = ComponentBase
 

Member Typedef Documentation

◆ LoggableComponentBase

using components::ComponentBase::LoggableComponentBase = ComponentBase
protectedinherited
Deprecated
use components::ComponentBase instead.

Definition at line 67 of file component_base.hpp.

Member Function Documentation

◆ 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.

◆ GetCoordinationClient()

std::shared_ptr< CoordinationClient > ydb::YdbComponent::GetCoordinationClient ( const std::string & dbname) const

Get coordination client

Parameters
dbnamedatabase name from static config key

◆ GetDatabasePath()

const std::string & ydb::YdbComponent::GetDatabasePath ( const std::string & dbname) const

Get database path

Parameters
dbnamedatabase name from static config key

◆ GetFederatedTopicClient()

std::shared_ptr< FederatedTopicClient > ydb::YdbComponent::GetFederatedTopicClient ( const std::string & dbname) const

Get topic client

Parameters
dbnamedatabase name from static config key
Examples
samples/ydb_service/components/federated_topic_reader.cpp.

◆ GetNativeDriver()

const NYdb::TDriver & ydb::YdbComponent::GetNativeDriver ( const std::string & dbname) const

Get native driver

Parameters
dbnamedatabase name from static config key
Warning
Use with care! Facilities from <core/include/userver/drivers/subscribable_futures.hpp> can help with non-blocking wait operations.

◆ GetTableClient()

std::shared_ptr< TableClient > ydb::YdbComponent::GetTableClient ( const std::string & dbname) const

Get table client

Parameters
dbnamedatabase name from static config key

◆ GetTopicClient()

std::shared_ptr< TopicClient > ydb::YdbComponent::GetTopicClient ( const std::string & dbname) const

Get topic client

Parameters
dbnamedatabase name from static config key
Examples
samples/ydb_service/components/topic_reader.cpp.

◆ 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.


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