Skip to content

Commit

Permalink
fix: RPC mode does not honor timeout
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
aepfli committed Feb 19, 2025
1 parent 122119b commit ee7ed54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class GrpcConnector<T extends AbstractStub<T>, K extends AbstractBlocking
/**
* The blocking service stub for making blocking GRPC calls.
*/
private final K blockingStub;
private final Function<ManagedChannel, K> blockingStubFunction;

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

private final FlagdOptions options;

/**
* Indicates whether the connector is currently connected to the GRPC service.
*/
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion providers/flagd/test-harness

0 comments on commit ee7ed54

Please sign in to comment.