userver: ugrpc::client Namespace Reference
Loading...
Searching...
No Matches
ugrpc::client Namespace Reference

Detailed Description

Client-side utilities.

Namespaces

namespace  middlewares

Classes

class  AbortedError
class  AlreadyExistsError
class  BaseError
 Base exception for all the client errors. More...
class  CallContext
 gRPC call context More...
class  CallOptions
 Options passed to interface calls. More...
class  CancelledError
 Concrete errors for all the error codes. More...
class  ClientFactory
 Creates gRPC clients. More...
class  ClientFactoryComponent
 Provides a ClientFactory in the component system. More...
struct  ClientFactorySettings
 Settings relating to the ClientFactory. More...
struct  ClientInfo
 Client meta info for a middleware construction. More...
struct  ClientQos
struct  ClientSettings
 Settings relating to creation of a code-generated client. More...
class  CommonComponent
 Contains common machinery that's required for all ugrpc clients. More...
class  DataLossError
class  DeadlineExceededError
class  ErrorWithStatus
 Error with grpc::Status details. More...
class  FailedPreconditionError
class  GenericClient
 Allows to talk to gRPC services (generic and normal) using dynamic method names. More...
struct  GenericOptions
struct  GlobalQos
class  InternalError
class  InvalidArgumentError
class  MiddlewareBase
 Base class for client gRPC middleware. More...
class  MiddlewareCallContext
 Context for middleware-specific data during gRPC call. More...
class  MiddlewarePipelineComponent
 Component to create middlewares pipeline. More...
class  NotFoundError
class  OutOfRangeError
class  PermissionDeniedError
struct  ProxySettings
struct  Qos
 Per-RPC quality-of-service config. Taken from ugrpc::client::ClientQos. Can also be passed to ugrpc client methods manually. More...
class  Reader
 Client-side interface for server-streaming. More...
class  ReaderWriter
 Client-side interface for bi-directional streaming. More...
class  ResourceExhaustedError
class  ResponseFuture
 Controls a single request -> single response RPC. More...
struct  RetryConfig
 Retry configuration for outgoing RPCs. More...
class  RetryLimiter
 Interface for controlling retry behavior based on request outcomes. More...
class  RetryLimiterFactory
 Abstract factory for creating RetryLimiter instances. More...
struct  RetryLimiterSettings
 Settings for a RetryLimiter instance. More...
class  RpcCancelledError
 RPC failed due to task cancellation. More...
class  RpcError
 Error during an RPC. More...
class  RpcInterruptedError
 RPC failed without a gRPC status because it was interrupted at the transport level (cancelled via TryCancel, or the connection was lost/reset). For a unary call it is thrown only when no concrete gRPC status is available; when a status is available it is instead surfaced as the corresponding ugrpc::client::ErrorWithStatus. Retryable. Note: Deadline expiration throws ugrpc::client::DeadlineExceededError. More...
class  SimpleClientComponent
 Template class for a simple gRPC client. More...
class  StreamReadFuture
 StreamReadFuture for waiting a single read response from stream. More...
class  UnauthenticatedError
class  UnavailableError
class  UnimplementedError
class  UnknownError
class  Writer
 Client-side interface for client-streaming. More...

Typedefs

using DedicatedMethodsConfig = std::unordered_map<std::string, std::size_t>
using CompletionStatus = utils::expected<grpc::Status, SpecialCaseCompletionType>
 Result type for gRPC client call completion.
using MiddlewareFactoryComponentBase
 Factory that creates specific client middlewares for clients.
template<typename Middleware>
using SimpleMiddlewareFactoryComponent
 The alias for a short-cut client factory.
using Middlewares = std::vector<std::shared_ptr<const MiddlewareBase>>
 A chain of middlewares.

Enumerations

enum class  AuthType {
  kInsecure ,
  kSsl
}
 Authentication method. More...
enum class  SpecialCaseCompletionType : std::uint8_t {
  SpecialCaseCompletionType::kNetworkError ,
  SpecialCaseCompletionType::kTimeoutDeadlinePropagated ,
  SpecialCaseCompletionType::kCancelled ,
  SpecialCaseCompletionType::kAbandoned
}
 Special completion types for gRPC client calls that don't result in a normal grpc::Status. More...

Functions

void ThrowErrorWithStatus (std::string_view call_name, grpc::Status &&status)
AuthType Parse (const yaml_config::YamlConfig &value, formats::parse::To< AuthType >)
std::shared_ptr< grpc::Channel > MakeChannel (engine::TaskProcessor &blocking_task_processor, std::shared_ptr< grpc::ChannelCredentials > channel_credentials, const std::string &endpoint)
 Create a new gRPC channel (connection pool) for the endpoint.
template<typename Client>
bool TryWaitForConnected (Client &client, engine::Deadline deadline, engine::TaskProcessor &blocking_task_processor)
 Wait until the channel state of client is READY. If the current state is already READY, returns true immediately. In case of multiple underlying channels, waits for all of them.
std::shared_ptr< grpc::ChannelCredentials > GetClientCredentials (const ClientFactorySettings &client_factory_settings, const std::string &client_name)
bool operator== (const GlobalQos &lhs, const GlobalQos &rhs) noexcept
GlobalQos Parse (const formats::json::Value &value, formats::parse::To< GlobalQos >)
formats::json::Value Serialize (const GlobalQos &, formats::serialize::To< formats::json::Value >)
bool operator== (const ClientQos &lhs, const ClientQos &rhs) noexcept
ClientQos Parse (const formats::json::Value &value, formats::parse::To< ClientQos >)
formats::json::Value Serialize (const ClientQos &client_qos, formats::serialize::To< formats::json::Value >)
std::size_t GetMethodChannelCount (const DedicatedMethodsConfig &dedicated_methods_config, std::string_view method_name)
std::string_view ToString (SpecialCaseCompletionType type)
 Convert SpecialCaseCompletionType to string representation.
std::string_view GetSpecialCaseCompletionTypeDescription (SpecialCaseCompletionType type)
 Convert SpecialCaseCompletionType to human-readable description.
components::ComponentList MinimalComponentList ()
 Returns a list of components to do a minimal grpc client configuration.
components::ComponentList DefaultComponentList ()
 Returns a list of components to do a default grpc client configuration.
template<typename Response>
std::optional< std::size_t > ReadRemainingAndFinish (Reader< Response > &stream) noexcept
 Read all remaining messages from the stream and call Finish.
template<typename Request, typename Response>
std::optional< std::size_t > ReadRemainingAndFinish (ReaderWriter< Request, Response > &stream) noexcept
 Announce end-of-input to the server, read all remaining messages from the stream and call Finish.
bool operator== (const Qos &lhs, const Qos &rhs) noexcept
Qos Parse (const formats::json::Value &value, formats::parse::To< Qos >)
formats::json::Value Serialize (const Qos &qos, formats::serialize::To< formats::json::Value >)
RetryConfig Parse (const yaml_config::YamlConfig &value, formats::parse::To< RetryConfig >)

Typedef Documentation

◆ DedicatedMethodsConfig

using ugrpc::client::DedicatedMethodsConfig = std::unordered_map<std::string, std::size_t>

Definition at line 20 of file client_settings.hpp.

◆ Middlewares

using ugrpc::client::Middlewares = std::vector<std::shared_ptr<const MiddlewareBase>>

A chain of middlewares.

Definition at line 16 of file fwd.hpp.

Enumeration Type Documentation

◆ AuthType

enum class ugrpc::client::AuthType
strong

Authentication method.

Definition at line 13 of file auth_type.hpp.

Function Documentation

◆ MakeChannel()

std::shared_ptr< grpc::Channel > ugrpc::client::MakeChannel ( engine::TaskProcessor & blocking_task_processor,
std::shared_ptr< grpc::ChannelCredentials > channel_credentials,
const std::string & endpoint )

Create a new gRPC channel (connection pool) for the endpoint.

Channel creation is expensive, reuse channels if possible.

Each channel is fully thread-safe: it can be used across multiple threads, possibly from multiple clients and using multiple CompletionQueue instances at the same time.

Parameters
blocking_task_processortask processor for blocking channel creation
channel_credentialschannel credentials
endpointstring host:port
Returns
shared pointer to the gRPC channel

◆ ReadRemainingAndFinish() [1/2]

template<typename Response>
std::optional< std::size_t > ugrpc::client::ReadRemainingAndFinish ( Reader< Response > & stream)
noexcept

Read all remaining messages from the stream and call Finish.

Warning
The method will hang indefenitely if the stream is never interrupted or closed by the server
Returns
the number of messages received from the stream; nullopt if the operation failed (i.e. due to task cancellation, the stream being already closed for reads, or the server returning an error status)

Definition at line 28 of file graceful_stream_finish.hpp.

◆ ReadRemainingAndFinish() [2/2]

template<typename Request, typename Response>
std::optional< std::size_t > ugrpc::client::ReadRemainingAndFinish ( ReaderWriter< Request, Response > & stream)
noexcept

Announce end-of-input to the server, read all remaining messages from the stream and call Finish.

Warning
The method will hang indefenitely if the stream is never interrupted or closed by the server
Returns
the number of messages received from the stream; nullopt if the operation failed (i.e. due to task cancellation, the stream being already closed for either reads or writes, or the server returning an error status)

Definition at line 48 of file graceful_stream_finish.hpp.

◆ TryWaitForConnected()

template<typename Client>
bool ugrpc::client::TryWaitForConnected ( Client & client,
engine::Deadline deadline,
engine::TaskProcessor & blocking_task_processor )
nodiscard

Wait until the channel state of client is READY. If the current state is already READY, returns true immediately. In case of multiple underlying channels, waits for all of them.

Returns
true if the state changed before deadline expired
Note
The wait operation does not support task cancellations

Definition at line 52 of file channels.hpp.