Grpc: Use a different method for the client id#609
Grpc: Use a different method for the client id#609zkao merged 2 commits intofarcaster-project:mainfrom
Conversation
Instead of appending an id to every single request that a client can issue, this commit introduces a method to leverage the existing id infrastructure provided by rust-microservices and its ServiceId. Grpcd now sends requests through the control bus with a special GrpcdClient Service Id as the source. Once these requests are handled in one of the other daemons, they now use a special `send_client_ctl` function that sends the request back to the original Grpc ServiceId and adds the GRpcClientId as the source of the request. This allows the Grpc daemon to extra the id from the source of its received requests and issue responses back to the correct grpc client.
zkao
left a comment
There was a problem hiding this comment.
i'm neutral on this one. The advantages it creates not clearly compensates for the hacky usage of headers
Do you have an alternative? |
maybe I did not get the problem it tries to solve correctly, could you please state it? i'd say adding optional input parameters to |
I'll restate it again. The Grpc server can have many clients, or even a single client issuing multiple requests of the same kind. To track these requests internally they require the inclusion of some form of unique request id per API call. With the current method every single cli command (to ensure that the grpc server and the cli have feature parity) would have to include such an Id. This greatly pollutes the code, since we'd have to pass these id's through multiple requests and would probably even need to persist them in the microservice runtime for some calls that result in a long chain of requests. So instead of adding this complicated handling of such an Id, I leveraged the existing esb infrastructure to convey this information when reporting results back to clients. |
|
Thank you for bearing with me. I'd just propose the minor diff, since the fn is called 2 files changed, 1 insertion(+), 2 deletions(-)
src/farcasterd/runtime.rs | 1 -
src/service.rs | 2 +-
modified src/farcasterd/runtime.rs
@@ -901,7 +901,6 @@ impl Runtime {
Request::GetInfo => {
debug!("farcasterd received GetInfo request");
self.send_client_ctl(
- ServiceBus::Ctl,
endpoints,
source,
Request::NodeInfo(NodeInfo {
modified src/service.rs
@@ -405,11 +405,11 @@ where
fn send_client_ctl(
&mut self,
- bus: ServiceBus,
senders: &mut Endpoints,
dest: ServiceId,
request: Request,
) -> Result<(), Error> {
+ let bus = ServiceBus::Ctl;
if let ServiceId::GrpcdClient(_) = dest {
senders.send_to(bus, dest, ServiceId::Grpcd, request)?;
} else { |
|
Thanks for the suggestion, done in 2d9bcfa |
Instead of appending an id to every single request that a client can issue, this commit introduces a method to leverage the existing id infrastructure provided by rust-microservices and its ServiceId.
Grpcd now sends requests through the control bus with a special GrpcdClient Service Id as the source. Once these requests are handled in one of the other daemons, they now use a special
send_client_ctlfunction that sends the request back to the original Grpc ServiceId and adds the GRpcClientId as the source of the request. This allows the Grpc daemon to extra the id from the source of its received requests and issue responses back to the correct grpc client.