Your opinion will help to improve our service
Leave a feedback >Asynchronous gRPC driver.
Namespaces | |
namespace | client |
Client-side utilities. | |
namespace | server |
Server-side utilities. | |
namespace | tests |
userver gRPC testing facilities | |
Classes | |
class | BaseVisitor |
Base class for FieldsVisitor and MessagesVisitor. Provides the interface and contains common code to use the data collected in the VisitorCompiler. More... | |
class | DateConversionError |
Exception thrown when date conversion functions receive/produce invalid google::type::Date accrording to IsValid or otherwise lead to undefined behavior due to integer overflow. More... | |
class | DurationConversionError |
Exception thrown when duration conversion functions receive/produce invalid google::protobuf::Duration accrording to IsValid or otherwise lead to undefined behavior due to integer overflow. More... | |
class | FieldsVisitor |
Collects knowledge of the structure of the protobuf messages allowing for efficient loops over fields to apply a callback to the ones selected by the 'selector' function. More... | |
class | MessagesVisitor |
Collects knowledge of the structure of the protobuf messages allowing for efficient loops over nested messages to apply a callback to the ones selected by the 'selector' function. More... | |
class | TimestampConversionError |
Exception thrown when timestamp conversion functions receive/produce invalid google::protobuf::Timestamp accrording to IsValid or otherwise lead to undefined behavior due to integer overflow. More... | |
class | VisitorCompiler |
Base class for BaseVisitor. Constructs and manages the descriptor graph to collect the data about the messages and enable the visitors to find all selected structures. More... | |
Typedefs | |
using | MessageVisitCallback = utils::function_ref< void(google::protobuf::Message &)> |
using | FieldVisitCallback = utils::function_ref< void(google::protobuf::Message &, const google::protobuf::FieldDescriptor &)> |
using | DescriptorList = std::vector< const google::protobuf::Descriptor * > |
using | FieldDescriptorList = std::vector< const google::protobuf::FieldDescriptor * > |
Functions | |
grpc::Status | ToGrpcStatus (const google::rpc::Status &gstatus) |
Converts google::rpc::Status from googleapis to grpc::Status . google::rpc::Status is used to initialize grpc::Status code and message and also added to status details. | |
std::optional< google::rpc::Status > | ToGoogleRpcStatus (const grpc::Status &status) |
Creates google::rpc::Status parsing it from grpc::Status details. | |
std::string | GetGStatusLimitedMessage (const google::rpc::Status &status) |
Outputs status to string using protobuf's text format. | |
gpr_timespec | DurationToTimespec (const engine::Deadline::Duration &duration) noexcept |
Converts engine::Deadline::Duration to gpr_timespec . | |
template<typename Rep , typename Period > | |
gpr_timespec | DurationToTimespec (const std::chrono::duration< Rep, Period > &duration) noexcept |
engine::Deadline::Duration | TimespecToDuration (gpr_timespec t) noexcept |
Converts gpr_timespec to engine::Deadline::Duration | |
gpr_timespec | DeadlineToTimespec (const engine::Deadline &deadline) noexcept |
Converts engine::Deadline to gpr_timespec . | |
engine::Deadline | TimespecToDeadline (gpr_timespec t) noexcept |
Converts gpr_timespec to engine::Deadline | |
grpc::ByteBuffer | SerializeToByteBuffer (const ::google::protobuf::Message &message, std::size_t block_size=kDefaultSerializeBlockSize) |
Serialize a Protobuf message to the wire format. | |
bool | ParseFromByteBuffer (grpc::ByteBuffer &&buffer, ::google::protobuf::Message &message) |
Parse a Protobuf message from the wire format. | |
bool | IsValid (const google::protobuf::Timestamp &grpc_ts) |
Checks if google::protobuf::Timestamp contains a valid value according to protobuf documentation. | |
template<class Duration > | |
google::protobuf::Timestamp | ToProtoTimestamp (const std::chrono::time_point< std::chrono::system_clock, Duration > &system_tp) |
Creates google::protobuf::Timestamp from std::chrono::time_point . | |
template<class Duration = std::chrono::system_clock::duration> | |
std::chrono::time_point< std::chrono::system_clock, Duration > | ToTimePoint (const google::protobuf::Timestamp &grpc_ts) |
Creates std::chrono::system_clock::time_point from google::protobuf::Timestamp . | |
google::protobuf::Timestamp | NowTimestamp () |
Returns current (possibly, mocked) timestamp as a google::protobuf::Timestamp . | |
bool | IsValid (const google::type::Date &grpc_date) |
Checks if google::type::Date contains a valid value according to protobuf documentation. | |
google::type::Date | ToProtoDate (const utils::datetime::Date &utils_date) |
Creates google::type::Date from utils::datetime::Date . | |
utils::datetime::Date | ToUtilsDate (const google::type::Date &grpc_date) |
Creates utils::datetime::Date from google::type::Date . | |
template<class Duration > | |
google::type::Date | ToProtoDate (const std::chrono::time_point< std::chrono::system_clock, Duration > &system_tp) |
Creates google::type::Date from std::chrono::time_point . | |
std::chrono::time_point< std::chrono::system_clock, utils::datetime::Days > | ToTimePoint (const google::type::Date &grpc_date) |
Creates std::chrono::system_clock::time_point from google::type::Date . | |
google::type::Date | NowDate () |
Returns current (possibly, mocked) timestamp as a google::type::Date . | |
bool | IsValid (const google::protobuf::Duration &grpc_duration) |
Checks if google::protobuf::Duration contains a valid value according to protobuf documentation. | |
template<class Duration = std::chrono::microseconds> | |
Duration | ToDuration (const google::protobuf::Duration &grpc_duration) |
Creates std::chrono::duration from google::protobuf::Duration . | |
template<class Rep , class Period > | |
google::protobuf::Duration | ToProtoDuration (const std::chrono::duration< Rep, Period > &duration) |
Creates google::protobuf::Duration from std::chrono::duration . | |
formats::json::Value | MessageToJson (const google::protobuf::Message &message) |
Returns formats::json::Value representation of protobuf message. | |
std::string | ToString (const google::protobuf::Message &message) |
Converts message to human readable string. | |
std::string | ToJsonString (const google::protobuf::Message &message) |
Returns Json-string representation of protobuf message. | |
formats::json::Value | MessageToJson (const google::protobuf::Message &message, const google::protobuf::util::JsonPrintOptions &options) |
Returns formats::json::Value representation of protobuf message. | |
std::string | ToJsonString (const google::protobuf::Message &message, const google::protobuf::util::JsonPrintOptions &options) |
Returns Json-string representation of protobuf message. | |
void | VisitFields (google::protobuf::Message &message, FieldVisitCallback callback) |
Execute a callback for all non-empty fields of the message. | |
void | VisitMessagesRecursive (google::protobuf::Message &message, MessageVisitCallback callback) |
Execute a callback for the message and its non-empty submessages. | |
void | VisitFieldsRecursive (google::protobuf::Message &message, FieldVisitCallback callback) |
Execute a callback for all fields of the message and its non-empty submessages. | |
void | VisitNestedMessage (google::protobuf::Message &message, const google::protobuf::FieldDescriptor &field, MessageVisitCallback callback) |
Execute a callback for the submessage contained in the given field. | |
FieldDescriptorList | GetFieldDescriptors (const google::protobuf::Descriptor &descriptor) |
Get the descriptors of fields in the message. | |
DescriptorList | GetNestedMessageDescriptors (const google::protobuf::Descriptor &descriptor) |
Get the descriptors of current and nested messages. | |
const google::protobuf::Descriptor * | FindGeneratedMessage (std::string_view name) |
Find a generated type by name. | |
const google::protobuf::FieldDescriptor * | FindField (const google::protobuf::Descriptor *descriptor, std::string_view field) |
Find the field of a generated type by name. | |
grpc::StatusCode | StatusCodeFromString (std::string_view str) |
Convert string to grpc::StatusCode. | |
std::string | ToString (grpc::StatusCode code) noexcept |
Convert grpc::StatusCode to string. | |
bool | IsServerError (grpc::StatusCode code) noexcept |
Whether a given status code is definitely a server-side error. | |
Variables | |
constexpr std::size_t | kDefaultSerializeBlockSize = 4096 |
using ugrpc::DescriptorList = typedef std::vector<const google::protobuf::Descriptor*> |
Definition at line 50 of file protobuf_visit.hpp.
using ugrpc::FieldDescriptorList = typedef std::vector<const google::protobuf::FieldDescriptor*> |
Definition at line 52 of file protobuf_visit.hpp.
using ugrpc::FieldVisitCallback = typedef utils::function_ref<void(google::protobuf::Message&, const google::protobuf::FieldDescriptor&)> |
Definition at line 31 of file protobuf_visit.hpp.
using ugrpc::MessageVisitCallback = typedef utils::function_ref<void(google::protobuf::Message&)> |
Definition at line 29 of file protobuf_visit.hpp.
|
noexcept |
Definition at line 15 of file time_utils.hpp.
|
noexcept |
Whether a given status code is definitely a server-side error.
Currently includes:
UNKNOWN
UNIMPLEMENTED
INTERNAL
UNAVAILABLE
DATA_LOSS
We intentionally do not include CANCELLED
and DEADLINE_EXPIRED
here, because the situation may either be considered not erroneous at all (when a client explicitly cancels an RPC; when a client attempts an RPC with a very short deadline), or there is no single obvious service to blame (when the collective deadline expires for an RPC tree).
bool ugrpc::IsValid | ( | const google::protobuf::Duration & | grpc_duration | ) |
Checks if google::protobuf::Duration
contains a valid value according to protobuf documentation.
Seconds must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years For durations of one second or more, a non-zero value for the nanos
field must be of the same sign as seconds
. Nanos must also be from -999,999,999 to +999,999,999 inclusive.
bool ugrpc::IsValid | ( | const google::protobuf::Timestamp & | grpc_ts | ) |
Checks if google::protobuf::Timestamp
contains a valid value according to protobuf documentation.
The timestamp must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive and 'nanos' must be from 0 to 999,999,999 inclusive.
bool ugrpc::IsValid | ( | const google::type::Date & | grpc_date | ) |
Checks if google::type::Date
contains a valid value according to protobuf documentation.
Year must be from 1 to 9999. Month must be from 1 to 12. Day must be from 1 to 31 and valid for the year and month.
formats::json::Value ugrpc::MessageToJson | ( | const google::protobuf::Message & | message | ) |
Returns formats::json::Value representation of protobuf message.
SerializationError |
formats::json::Value ugrpc::MessageToJson | ( | const google::protobuf::Message & | message, |
const google::protobuf::util::JsonPrintOptions & | options | ||
) |
Returns formats::json::Value representation of protobuf message.
SerializationError |
bool ugrpc::ParseFromByteBuffer | ( | grpc::ByteBuffer && | buffer, |
::google::protobuf::Message & | message | ||
) |
Parse a Protobuf message from the wire format.
buffer | the buffer that might be tempered with during deserialization |
message | will contain the parsing result on success |
true
on success, false
if buffer does not contain a valid message, according to the derived type of message grpc::ByteBuffer ugrpc::SerializeToByteBuffer | ( | const ::google::protobuf::Message & | message, |
std::size_t | block_size = kDefaultSerializeBlockSize |
||
) |
Serialize a Protobuf message to the wire format.
message | the message to serialize |
block_size | can be used for performance tuning, too small chunk size results in extra allocations, too large chunk size results in wasting memory |
std::runtime_error | on serialization errors (supposedly only happens on extremely rare allocation failures or proto reflection malfunctioning). |
grpc::StatusCode ugrpc::StatusCodeFromString | ( | std::string_view | str | ) |
Convert string to grpc::StatusCode.
std::runtime_error |
Duration ugrpc::ToDuration | ( | const google::protobuf::Duration & | grpc_duration | ) |
Creates std::chrono::duration
from google::protobuf::Duration
.
DurationConversionError | if the value is not valid according to IsValid or does not fit the Duration. |
Definition at line 154 of file datetime_utils.hpp.
std::string ugrpc::ToJsonString | ( | const google::protobuf::Message & | message | ) |
Returns Json-string representation of protobuf message.
formats::json::Exception |
std::string ugrpc::ToJsonString | ( | const google::protobuf::Message & | message, |
const google::protobuf::util::JsonPrintOptions & | options | ||
) |
Returns Json-string representation of protobuf message.
formats::json::Exception |
google::type::Date ugrpc::ToProtoDate | ( | const std::chrono::time_point< std::chrono::system_clock, Duration > & | system_tp | ) |
Creates google::type::Date
from std::chrono::time_point
.
DateConversionError | if the value is not valid according to IsValid . |
Definition at line 122 of file datetime_utils.hpp.
google::type::Date ugrpc::ToProtoDate | ( | const utils::datetime::Date & | utils_date | ) |
Creates google::type::Date
from utils::datetime::Date
.
DateConversionError | if the value is not valid according to IsValid . |
google::protobuf::Duration ugrpc::ToProtoDuration | ( | const std::chrono::duration< Rep, Period > & | duration | ) |
Creates google::protobuf::Duration
from std::chrono::duration
.
DurationConversionError | if the value is not valid according to IsValid . |
Definition at line 174 of file datetime_utils.hpp.
google::protobuf::Timestamp ugrpc::ToProtoTimestamp | ( | const std::chrono::time_point< std::chrono::system_clock, Duration > & | system_tp | ) |
Creates google::protobuf::Timestamp
from std::chrono::time_point
.
TimestampConversionError | if the value is not valid according to IsValid . |
Definition at line 41 of file datetime_utils.hpp.
std::chrono::time_point< std::chrono::system_clock, Duration > ugrpc::ToTimePoint | ( | const google::protobuf::Timestamp & | grpc_ts | ) |
Creates std::chrono::system_clock::time_point
from google::protobuf::Timestamp
.
TimestampConversionError | if the value is not valid according to IsValid or does not fit the time_point. |
Definition at line 61 of file datetime_utils.hpp.
std::chrono::time_point< std::chrono::system_clock, utils::datetime::Days > ugrpc::ToTimePoint | ( | const google::type::Date & | grpc_date | ) |
Creates std::chrono::system_clock::time_point
from google::type::Date
.
DateConversionError | if the value is not valid according to IsValid . |
utils::datetime::Date ugrpc::ToUtilsDate | ( | const google::type::Date & | grpc_date | ) |
Creates utils::datetime::Date
from google::type::Date
.
DateConversionError | if the value is not valid according to IsValid . |
|
inlineconstexpr |
Definition at line 16 of file byte_buffer_utils.hpp.