Skip to content

Commit 9240d70

Browse files
committed
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 <[email protected]>
1 parent 122119b commit 9240d70

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/common/GrpcConnector.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class GrpcConnector<T extends AbstractStub<T>, K extends AbstractBlocking
3232
/**
3333
* The blocking service stub for making blocking GRPC calls.
3434
*/
35-
private final K blockingStub;
35+
private final Function<ManagedChannel, K> blockingStubFunction;
3636

3737
/**
3838
* The GRPC managed channel for managing the underlying GRPC connection.
@@ -59,6 +59,8 @@ public class GrpcConnector<T extends AbstractStub<T>, K extends AbstractBlocking
5959
*/
6060
private final Consumer<T> streamObserver;
6161

62+
private final FlagdOptions options;
63+
6264
/**
6365
* Indicates whether the connector is currently connected to the GRPC service.
6466
*/
@@ -85,11 +87,12 @@ public GrpcConnector(
8587

8688
this.channel = channel;
8789
this.serviceStub = stub.apply(channel).withWaitForReady();
88-
this.blockingStub = blockingStub.apply(channel).withWaitForReady();
90+
this.blockingStubFunction = blockingStub;
8991
this.deadline = options.getDeadline();
9092
this.streamDeadlineMs = options.getStreamDeadlineMs();
9193
this.onConnectionEvent = onConnectionEvent;
9294
this.streamObserver = eventStreamObserver;
95+
this.options = options;
9396
}
9497

9598
/**
@@ -126,7 +129,7 @@ public void initialize() throws Exception {
126129
* @return the blocking service stub
127130
*/
128131
public K getResolver() {
129-
return blockingStub;
132+
return blockingStubFunction.apply(channel).withWaitForReady().withDeadlineAfter(options.getDeadline(), TimeUnit.MILLISECONDS);
130133
}
131134

132135
/**

providers/flagd/test-harness

0 commit comments

Comments
 (0)