66 typename TGrpcChannel,
67 typename TGrpcClientCredentials,
68 typename TGrpcChannelArguments,
69 typename TGrpcCompressionAlgorithm
99template <
typename TParams,
typename Traits>
119 std::shared_ptr<Channel> (*
fptr)(
const std::string&,
120 const std::shared_ptr<Credentials>&,
134 std::unique_ptr<typename Service::Stub>
stub_;
157 TEC_ENTER(
"GrpcClient::set_channel_arguments");
160 if (
params_.max_message_size > 0) {
162 const int max_size =
params_.max_message_size * 1024 * 1024;
164 arguments_.SetMaxReceiveMessageSize(max_size);
170 if (
params_.compression_algorithm > 0) {
173 TEC_TRACE(
"CompressionAlgorithm is set to {}.",
params_.compression_algorithm);
186 const std::shared_ptr<Credentials>& credentials)
193 std::is_base_of<GrpcClientParams, Params>::value,
194 "Must be derived from tec::GrpcClientParams class");
223 auto deadline = std::chrono::system_clock::now() +
params_.connect_timeout;
224 if (!
channel_->WaitForConnected(deadline)) {
226 "It took too long (> {} ms) to reach out the server on \"{}\"",
Abstract base class defining the actor lifecycle and request handling interface.
Definition tec_actor.hpp:63
Base class for actor-style asynchronous gRPC clients.
Definition tec_grpc_client.hpp:100
traits::Credentials Credentials
credentials type
Definition tec_grpc_client.hpp:106
void shutdown(Signal *sig_stopped) override
Graceful shutdown hook.
Definition tec_grpc_client.hpp:246
virtual Status process_request(Request request, Reply reply) override
Processes a single request → reply pair.
Definition tec_grpc_client.hpp:263
std::shared_ptr< Credentials > credentials_
Credentials object used to create secure/insecure channels.
Definition tec_grpc_client.hpp:131
traits::Service Service
gRPC service stub type
Definition tec_grpc_client.hpp:104
TParams Params
Configuration parameters type.
Definition tec_grpc_client.hpp:103
ChannelBuilder channel_builder_
Channel creation functor (injected at construction)
Definition tec_grpc_client.hpp:137
GrpcClient(const Params ¶ms, const ChannelBuilder &channel_builder, const std::shared_ptr< Credentials > &credentials)
Constructs a GrpcClient instance.
Definition tec_grpc_client.hpp:184
Arguments arguments_
Channel creation arguments (message size limits, compression, keepalive, etc.)
Definition tec_grpc_client.hpp:143
virtual ~GrpcClient()=default
Virtual destructor (defaulted)
traits::Channel Channel
gRPC channel type
Definition tec_grpc_client.hpp:105
std::unique_ptr< typename Service::Stub > stub_
Owned stub instance — created after successful channel connection.
Definition tec_grpc_client.hpp:134
void start(Signal *sig_started, Status *status) override
Establishes connection to the gRPC server.
Definition tec_grpc_client.hpp:211
traits::CompressionAlgorithm CompressionAlgorithm
compression enum type
Definition tec_grpc_client.hpp:108
traits::Arguments Arguments
channel arguments type
Definition tec_grpc_client.hpp:107
std::shared_ptr< Channel > channel_
Shared pointer to the active gRPC channel.
Definition tec_grpc_client.hpp:140
Params params_
Runtime configuration parameters (address, timeouts, message size, compression, etc....
Definition tec_grpc_client.hpp:128
Traits traits
Traits providing all gRPC-related type aliases.
Definition tec_grpc_client.hpp:102
virtual void set_channel_arguments()
Configures channel arguments before channel creation.
Definition tec_grpc_client.hpp:156
A thread-safe signal mechanism for inter-thread synchronization.
Definition tec_signal.hpp:44
#define TEC_ENTER(name)
Logs an entry message for a named context (e.g., function).
Definition tec_trace.hpp:211
#define TEC_TRACE(...)
Logs a formatted trace message.
Definition tec_trace.hpp:222
@ NetErr
Network-related error.
@ NotImplemented
Not implemented.
Holder for a function pointer that creates a gRPC channel.
Definition tec_grpc_client.hpp:117
std::shared_ptr< Channel >(* fptr)(const std::string &, const std::shared_ptr< Credentials > &, const Arguments &)
Function pointer matching signature of grpc::CreateChannel / CreateCustomChannel / etc.
Definition tec_grpc_client.hpp:119
Helper struct to signal termination on exit.
Definition tec_signal.hpp:110
Type traits / type aliases collection for configuring a gRPC client.
Definition tec_grpc_client.hpp:71
TGrpcCompressionAlgorithm CompressionAlgorithm
supported compression algorithms enum
Definition tec_grpc_client.hpp:76
TService Service
gRPC service stub type
Definition tec_grpc_client.hpp:72
TGrpcChannel Channel
gRPC channel type
Definition tec_grpc_client.hpp:73
TGrpcChannelArguments Arguments
channel creation arguments
Definition tec_grpc_client.hpp:75
TGrpcClientCredentials Credentials
credentials factory type
Definition tec_grpc_client.hpp:74
Core interface for TEC actors with lifecycle management and request processing.
Common definitions and utilities for the tec namespace.
std::any Reply
Type alias for a reply object that can hold any object.
Definition tec_message.hpp:55
std::any Request
Type alias for a request object that can hold any object.
Definition tec_message.hpp:49
std::string format(const T &arg)
Formats a single argument into a string.
Definition tec_print.hpp:171
Defines error handling types and utilities for the tec namespace.
Provides a thread-safe tracing utility for debugging in the tec namespace.
Provides time-related utilities and system information functions for the tec namespace.
std::chrono::milliseconds MilliSec
Type alias for milliseconds duration.
Definition tec_utils.hpp:62