Skip to content

Commit

Permalink
Use supplier in order to properly have mutiny retry
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Feb 21, 2024
1 parent 266f49b commit e3af735
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.time.Duration;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Supplier;
Expand All @@ -22,7 +23,6 @@
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.quarkus.vertx.core.runtime.BufferOutputStream;
import io.smallrye.mutiny.Uni;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
Expand Down Expand Up @@ -109,8 +109,14 @@ private static void initiateSend(GrpcClient client, SocketAddress server,
int numberOfAttempts,
Handler<GrpcClientRequest<Buffer, Buffer>> onSuccessHandler,
Consumer<Throwable> onFailureCallback) {
Future<GrpcClientRequest<Buffer, Buffer>> reqFuture = client.request(server);
Uni.createFrom().completionStage(reqFuture.toCompletionStage()).onFailure().retry().withBackOff(Duration.ofMillis(100))
Uni.createFrom().completionStage(new Supplier<CompletionStage<GrpcClientRequest<Buffer, Buffer>>>() {

@Override
public CompletionStage<GrpcClientRequest<Buffer, Buffer>> get() {
return client.request(server).toCompletionStage();
}
}).onFailure().retry()
.withBackOff(Duration.ofMillis(100))
.atMost(numberOfAttempts).subscribe().with(
new Consumer<>() {
@Override
Expand Down

0 comments on commit e3af735

Please sign in to comment.