From 9240d70fc831dd2abfc7b39ef4b45fef1614d865 Mon Sep 17 00:00:00 2001 From: Simon Schrottner Date: Wed, 19 Feb 2025 08:45:01 +0100 Subject: [PATCH] fix: RPC mode does not honor timeout During the refactoring of the connection the timeout for unary calls got lost. This adds the timeout back into the mix. TODO: - [ ] adapt gherkin tests for contextEnrichment to do handle stale seperately for file and inprocess Signed-off-by: Simon Schrottner --- .../providers/flagd/resolver/common/GrpcConnector.java | 9 ++++++--- providers/flagd/test-harness | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/GrpcConnector.java b/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/GrpcConnector.java index ae83227f23..21dc567a27 100644 --- a/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/GrpcConnector.java +++ b/providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/GrpcConnector.java @@ -32,7 +32,7 @@ public class GrpcConnector, K extends AbstractBlocking /** * The blocking service stub for making blocking GRPC calls. */ - private final K blockingStub; + private final Function blockingStubFunction; /** * The GRPC managed channel for managing the underlying GRPC connection. @@ -59,6 +59,8 @@ public class GrpcConnector, K extends AbstractBlocking */ private final Consumer streamObserver; + private final FlagdOptions options; + /** * Indicates whether the connector is currently connected to the GRPC service. */ @@ -85,11 +87,12 @@ public GrpcConnector( this.channel = channel; this.serviceStub = stub.apply(channel).withWaitForReady(); - this.blockingStub = blockingStub.apply(channel).withWaitForReady(); + this.blockingStubFunction = blockingStub; this.deadline = options.getDeadline(); this.streamDeadlineMs = options.getStreamDeadlineMs(); this.onConnectionEvent = onConnectionEvent; this.streamObserver = eventStreamObserver; + this.options = options; } /** @@ -126,7 +129,7 @@ public void initialize() throws Exception { * @return the blocking service stub */ public K getResolver() { - return blockingStub; + return blockingStubFunction.apply(channel).withWaitForReady().withDeadlineAfter(options.getDeadline(), TimeUnit.MILLISECONDS); } /** diff --git a/providers/flagd/test-harness b/providers/flagd/test-harness index 34a0c31765..4763b1ccca 160000 --- a/providers/flagd/test-harness +++ b/providers/flagd/test-harness @@ -1 +1 @@ -Subproject commit 34a0c31765041fc070a89eb4241859c5453a26a4 +Subproject commit 4763b1cccad17c25ca6ae8e1e59a2a40ade36ed1