|
TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
|
Base class for actor-style asynchronous gRPC clients. More...
#include <tec_grpc_client.hpp>
Classes | |
| struct | ChannelBuilder |
| Holder for a function pointer that creates a gRPC channel. More... | |
Public Types | |
| typedef Traits | traits |
| Traits providing all gRPC-related type aliases. | |
| typedef TParams | Params |
| Configuration parameters type. | |
| typedef traits::Service | Service |
| gRPC service stub type | |
| typedef traits::Channel | Channel |
| gRPC channel type | |
| typedef traits::Credentials | Credentials |
| credentials type | |
| typedef traits::Arguments | Arguments |
| channel arguments type | |
| typedef traits::CompressionAlgorithm | CompressionAlgorithm |
| compression enum type | |
Public Member Functions | |
| GrpcClient (const Params ¶ms, const ChannelBuilder &channel_builder, const std::shared_ptr< Credentials > &credentials) | |
| Constructs a GrpcClient instance. | |
| virtual | ~GrpcClient ()=default |
| Virtual destructor (defaulted) | |
| void | start (Signal *sig_started, Status *status) override |
| Establishes connection to the gRPC server. | |
| void | shutdown (Signal *sig_stopped) override |
| Graceful shutdown hook. | |
| virtual Status | process_request (Request request, Reply reply) override |
| Processes a single request → reply pair. | |
Public Member Functions inherited from tec::Actor | |
| Actor ()=default | |
| Default constructor. | |
| Actor (const Actor &)=delete | |
| Deleted copy constructor. | |
| Actor (Actor &&)=delete | |
| Deleted move constructor. | |
| Actor & | operator= (const Actor &)=delete |
| Deleted copy assignment operator. | |
| Actor & | operator= (Actor &&)=delete |
| Deleted move assignment operator. | |
| virtual | ~Actor ()=default |
| Virtual destructor. | |
| virtual Status | run () |
| Mimics Daemon's behavior. | |
| virtual Status | terminate () |
| Mimics Daemon's behavior. | |
Protected Member Functions | |
| virtual void | set_channel_arguments () |
| Configures channel arguments before channel creation. | |
Protected Attributes | |
| Params | params_ |
| Runtime configuration parameters (address, timeouts, message size, compression, etc.) | |
| std::shared_ptr< Credentials > | credentials_ |
| Credentials object used to create secure/insecure channels. | |
| std::unique_ptr< typename Service::Stub > | stub_ |
| Owned stub instance — created after successful channel connection. | |
| ChannelBuilder | channel_builder_ |
| Channel creation functor (injected at construction) | |
| std::shared_ptr< Channel > | channel_ |
| Shared pointer to the active gRPC channel. | |
| Arguments | arguments_ |
| Channel creation arguments (message size limits, compression, keepalive, etc.) | |
Base class for actor-style asynchronous gRPC clients.
Provides common infrastructure for creating and managing a gRPC channel, configuring message size limits and compression, connecting with timeout, and creating a service stub.
Concrete clients should inherit from this class and implement process_request() to perform actual RPC calls.
| TParams | User-defined parameter structure (must derive from GrpcClientParams) |
| Traits | Instance of grpc_client_traits<...> defining all gRPC-related types |
|
inline |
Constructs a GrpcClient instance.
| params | Configuration parameters (address, timeouts, limits…) |
| channel_builder | Functor responsible for creating the gRPC channel |
| credentials | Credentials to use (insecure / SSL / custom) |
|
inlineoverridevirtual |
Processes a single request → reply pair.
Pure virtual in the base class — must be implemented by derived classes. This is where actual RPC calls (unary, client-streaming, server-streaming, bidi) should be performed.
| request | Input request message |
| reply | Output reply message (to be filled) |
Implements tec::Actor.
|
inlineprotectedvirtual |
Configures channel arguments before channel creation.
Called automatically during start(). Sets maximum send/receive message sizes and compression algorithm according to values in params_.
Can be overridden in derived classes to set additional channel arguments (e.g. keep-alive, HTTP/2 settings, custom interceptors, etc.).
|
inlineoverridevirtual |
Graceful shutdown hook.
Currently only logs; derived classes may override to drain queues, cancel pending RPCs, etc.
| sig_stopped | Signal to notify when shutdown is complete |
Implements tec::Actor.
|
inlineoverridevirtual |
Establishes connection to the gRPC server.
| sig_started | Signal to notify when initialization completes |
| status | [out] Connection result status |
Implements tec::Actor.