userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
client_factory_component.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/ugrpc/client/client_factory_component.hpp
4
/// @brief @copybrief ugrpc::client::ClientFactoryComponent
5
6
#
include
<
userver
/
components
/
component_base
.
hpp
>
7
#
include
<
userver
/
middlewares
/
runner
.
hpp
>
8
9
#
include
<
userver
/
ugrpc
/
client
/
client_factory
.
hpp
>
10
#
include
<
userver
/
ugrpc
/
client
/
middlewares
/
base
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
ugrpc::client {
15
16
namespace
impl {
17
18
/// @brief The interface for a `ClientFactoryComponent` component. So, `ClientFactoryComponent` runs with middlewares.
19
using
MiddlewareRunnerComponentBase = USERVER_NAMESPACE::middlewares::
RunnerComponentBase
<
MiddlewareBase
, ClientInfo>;
20
21
}
// namespace impl
22
23
/// @ingroup userver_components
24
///
25
/// @brief Provides a ClientFactory in the component system
26
///
27
/// Multiple ClientFactoryComponent instances may be created if different
28
/// parameters are required for different clients.
29
///
30
/// Requires ugrpc::client::CommonComponent.
31
///
32
/// ## Authentication
33
/// Authentication is controlled by `auth-type` static config field.
34
/// Possible values:
35
/// - `insecure` (`InsecureChannelCredentials` - default)
36
/// - `ssl` (`SslCredentials`)
37
///
38
/// Default (system) authentication keys are used regardless of the chosen
39
/// auth-type.
40
///
41
/// ## Service config
42
/// As per https://github.com/grpc/grpc/blob/master/doc/service_config.md
43
/// service config should be distributed via the name resolution process.
44
/// We allow setting default service_config: pass desired JSON literal to `default-service-config` parameter
45
///
46
/// ## Dynamic config bootstrap
47
/// By default this component waits for @ref components::DynamicConfig to load the first successful dynamic config
48
/// update (via @ref components::DynamicConfig::GetSource() "GetSource()"), which may block component construction.
49
/// Set `use-constant-dynamic-configs: true` to instead use
50
/// @ref components::DynamicConfig::GetDefaultsAsConstantSource() "GetDefaultsAsConstantSource()" — a non-blocking,
51
/// constant @ref dynamic_config::Source built from @ref components::DynamicConfig's own fallback defaults. This is
52
/// useful e.g. for a gRPC client used to deliver dynamic configs to the service itself, where waiting for
53
/// @ref components::DynamicConfig would create a bootstrap cycle.
54
///
55
/// When `use-constant-dynamic-configs` is in effect, this component also skips
56
/// @ref ugrpc::client::CommonComponent's shared default `retry-limiter` (as set by `grpc-client-common`'s
57
/// `retry-limiter`/`retry-limiter-enabled` options), since that default implementation may itself depend on
58
/// @ref components::DynamicConfig (e.g. the standard `statistics-retry-limiter` component), which would reintroduce
59
/// the same bootstrap dependency. An explicit `retry-limiter` specified directly in this component's own static
60
/// config is still always honored, regardless of `use-constant-dynamic-configs`; set it to `none` to force no
61
/// retry-limiter at all for this factory, even if a `grpc-client-common` default is configured.
62
///
63
/// ## Example: a "light" client factory used to deliver dynamic configs to the service itself
64
/// @snippet grpc/functional_tests/light_client/static_config.yaml Sample light grpc client factory config
65
///
66
/// ## Static options of ugrpc::client::ClientFactoryComponent :
67
/// @include{doc} scripts/docs/en/components_schema/grpc/src/ugrpc/client/client_factory_component.md
68
///
69
/// Options inherited from @ref middlewares::RunnerComponentBase :
70
/// @include{doc} scripts/docs/en/components_schema/core/src/middlewares/runner_component_base.md
71
///
72
/// Options inherited from @ref components::ComponentBase :
73
/// @include{doc} scripts/docs/en/components_schema/core/src/components/impl/component_base.md
74
///
75
/// The default component name for static config is `"grpc-client-factory"`.
76
///
77
/// @see https://grpc.github.io/grpc/core/group__grpc__arg__keys.html
78
class
ClientFactoryComponent
final
:
public
impl::MiddlewareRunnerComponentBase {
79
public
:
80
/// @ingroup userver_component_names
81
/// @brief The default name of ugrpc::client::middlewares::log::Component
82
static
constexpr
std::string_view
kName
=
"grpc-client-factory"
;
83
84
ClientFactoryComponent(
const
components
::ComponentConfig& config,
const
components
::ComponentContext& context);
85
86
ClientFactory& GetFactory();
87
88
static
yaml_config::Schema GetStaticConfigSchema();
89
90
private
:
91
std::optional<ClientFactory> factory_;
92
};
93
94
}
// namespace ugrpc::client
95
96
template
<>
97
inline
constexpr
bool
components
::kHasValidate<ugrpc::client::ClientFactoryComponent> =
true
;
98
99
USERVER_NAMESPACE_END
userver
ugrpc
client
client_factory_component.hpp
Generated on
for userver by
Doxygen
1.17.0