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::CoordinationClient.

Static options:

Name Description Default value
credentials-provider name of credentials provider component -
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 in milliseconds 5s
databases.<dbname>.endpoint gRPC endpoint URL, e.g. grpc://localhost:1234 -
databases.<dbname>.database full database path, e.g. /ru/service/production/database -
databases.<dbname>.credentials credentials config passed to credentials provider component -
databases.<dbname>.min_pool_size minimum pool size for database with name <dbname> 10
databases.<dbname>.max_pool_size maximum pool size for database with name <dbname> 50
databases.<dbname>.get_session_retry_limit retries count to get session, every attempt with a get-session-timeout 5
databases.<dbname>.keep-in-query-cache whether to use query cache true
databases.<dbname>.prefer_local_dc prefer making requests to local DataCenter false
databases.<dbname>.aliases list of alias names for this database []
databases.<dbname>.sync_start fail on boot time if YDB is not accessible true
databases.<dbname>.by-database-timings-buckets-ms histogram bounds for by-database timing metrics 40 buckets with +20% increment per step
databases.<dbname>.by-query-timings-buckets-ms histogram bounds for by-query timing metrics 15 buckets with +100% increment per step

Definition at line 62 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< 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
 Legacy alias, use ComponentBase instead.
 

Member Typedef Documentation

◆ LoggableComponentBase

using components::ComponentBase::LoggableComponentBase = ComponentBase
protectedinherited

Legacy alias, use ComponentBase instead.

Definition at line 69 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.

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

◆ 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

◆ 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 urabbitmq::ConsumerComponentBase, and components::Server.

Definition at line 60 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 urabbitmq::ConsumerComponentBase, components::Server, and server::handlers::Ping.

Definition at line 53 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 44 of file component_base.hpp.


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