RpcSendService
Service class responsible for handling RPC (Remote Procedure Call) communication over a WebSocket session.
This class provides methods for sending various types of requests and handling the responses in a clustered system. The communication is conducted via serialization and deserialization of messages using Kotlin serialization with ProtoBuf format.
Parameters
Factory for creating logger instances for this service to enable structured logging during communication and debugging.
The ProtoBuf serializer used for encoding and decoding messages.
The WebSocket session over which the RPC requests and responses are transmitted.
This class includes support for the following operations:
Sending an echo message.
Sending fire-and-forget messages (tell).
Sending requests with expected responses (ask).
Querying the status and statistics of a remote actor.
Initiating the shutdown of a remote actor.
Closing the WebSocket session when communication is complete.
The service ensures reliability and data consistency by validating response IDs with the request IDs during each interaction. Any inconsistency raises an error, ensuring the integrity of the communication process.
Additional functionality is provided via a companion object:
Managing a shared RPC message dispatcher that associates responses to their corresponding requests.
Ensuring unique message IDs for requests by maintaining an internal counter with safe concurrent access.
Handling incoming responses sent from the remote side by deserializing and forwarding them to the RPC manager.
Constructors
Functions
Sends a message to a specified actor address and waits for a response, ensuring the response corresponds to the sent request.
Sends an echo request with a given message and awaits a response.
Sends a shutdown request to the specified actor address and waits for the response.
Sends a stats request to the specified actor address and waits for the corresponding response.
Sends a status request to the specified actor address and awaits the corresponding response.
Sends a message to a specified actor address and waits for a response.