From a3f206fcce874d4d98de9280c7f4ae67a57dc207 Mon Sep 17 00:00:00 2001 From: Marius Vlad Date: Wed, 11 Dec 2024 13:30:56 +0200 Subject: AglShellGrpcClient: Add wait_for_ready + deadline for grpc::Context It seems that gRPC channel might not be ready when issueing floating request so add a wait_for_ready + deadline to make sure we don't send the request until the channel is available. Initial testing (though we might need more) shows that this fixes the issue. The way this works is that the client (if started with wait_for_ready set to true, passed in the AglShellGrpcClient constructor) will wait for the channel to be ready and then issue a floating request. There's a hidden deadline of 2 seconds in case that doesn't happen. Bug-AGL: SPEC-5235 Signed-off-by: Marius Vlad Change-Id: I40a5ad0dd760dc4559839ae7c302c1d6bc1ff973 --- app/AglShellGrpcClient.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/AglShellGrpcClient.h') diff --git a/app/AglShellGrpcClient.h b/app/AglShellGrpcClient.h index f66b44c..5030359 100644 --- a/app/AglShellGrpcClient.h +++ b/app/AglShellGrpcClient.h @@ -13,6 +13,7 @@ #include #include "agl_shell.grpc.pb.h" +#include typedef void (*Callback)(agl_shell_ipc::AppStateResponse app_response); @@ -88,7 +89,7 @@ private: class GrpcClient { public: - GrpcClient(); + GrpcClient(bool wait_for_ready); bool ActivateApp(const std::string& app_id, const std::string& output_name); bool DeactivateApp(const std::string& app_id); bool SetAppFloat(const std::string& app_id, int32_t x_pos, int32_t y_pos); @@ -106,6 +107,8 @@ public: private: Reader *reader; + bool wait_for_ready_{false}; + std::chrono::milliseconds deadline_; std::unique_ptr m_stub; }; -- cgit 1.2.3-korg