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

Detailed Description

Asynchronous gRPC driver.

Namespaces

namespace  client
 Client-side utilities.
 
namespace  server
 Server-side utilities.
 
namespace  tests
 userver gRPC testing facilities
 

Functions

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.
 
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.
 
grpc::StatusCode StatusCodeFromString (std::string_view str)
 Convert string to grpc::StatusCode.
 
std::string_view ToString (grpc::StatusCode code) noexcept
 Convert grpc::StatusCode to string.
 

Variables

constexpr std::size_t kDefaultSerializeBlockSize = 4096
 

Function Documentation

◆ MessageToJson()

formats::json::Value ugrpc::MessageToJson ( const google::protobuf::Message & message)

Returns formats::json::Value representation of protobuf message.

Exceptions
SerializationError

◆ ParseFromByteBuffer()

bool ugrpc::ParseFromByteBuffer ( grpc::ByteBuffer && buffer,
::google::protobuf::Message & message )

Parse a Protobuf message from the wire format.

Parameters
bufferthe buffer that might be tempered with during deserialization
messagewill contain the parsing result on success
Returns
true on success, false if buffer does not contain a valid message, according to the derived type of message

◆ SerializeToByteBuffer()

grpc::ByteBuffer ugrpc::SerializeToByteBuffer ( const ::google::protobuf::Message & message,
std::size_t block_size = kDefaultSerializeBlockSize )

Serialize a Protobuf message to the wire format.

Parameters
messagethe message to serialize
block_sizecan be used for performance tuning, too small chunk size results in extra allocations, too large chunk size results in wasting memory
Exceptions
std::runtime_erroron serialization errors (supposedly only happens on extremely rare allocation failures or proto reflection malfunctioning).

◆ StatusCodeFromString()

grpc::StatusCode ugrpc::StatusCodeFromString ( std::string_view str)

Convert string to grpc::StatusCode.

Exceptions
std::runtime_error

◆ ToJsonString()

std::string ugrpc::ToJsonString ( const google::protobuf::Message & message)

Returns Json-string representation of protobuf message.

Exceptions
formats::json::Exception

Variable Documentation

◆ kDefaultSerializeBlockSize

constexpr std::size_t ugrpc::kDefaultSerializeBlockSize = 4096
inlineconstexpr
See also
SerializeToByteBuffer

Definition at line 16 of file byte_buffer_utils.hpp.