Skip to content

Commit

Permalink
Update to executeBlocking API change
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jul 19, 2023
1 parent d562e1a commit 9a99a8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/main/java/examples/hystrix/HystrixExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void exampleHystrix1() {

public void exampleHystrix2(Vertx vertx) {
HystrixCommand<String> someCommand = getSomeCommandInstance();
vertx.<String>executeBlocking(
future -> future.complete(someCommand.execute())).onComplete(ar -> {
vertx.executeBlocking(
() -> someCommand.execute()).onComplete(ar -> {
// back on the event loop
String result = ar.result();
}
Expand Down
48 changes: 20 additions & 28 deletions src/test/java/io/vertx/circuitbreaker/impl/HystrixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public void testOk() throws Exception {
vertx.runOnContext(v -> {

// Blocking call..., need to run in an executeBlocking
vertx.<String>executeBlocking(
future -> {
HttpClientCommand command = new HttpClientCommand(client, "/");
future.complete(command.execute());
}).onComplete(ar -> result.set(ar.result())
vertx.executeBlocking(
() -> {
HttpClientCommand command = new HttpClientCommand(client, "/");
return command.execute();
}).onComplete(ar -> result.set(ar.result())
);
});

Expand All @@ -112,15 +112,11 @@ public void testOk() throws Exception {
vertx.runOnContext(v -> {

// Blocking call..., need to run in an executeBlocking
vertx.<String>executeBlocking(
future -> {
HttpClientCommand command = new HttpClientCommand(client, "/");
try {
future.complete(command.queue().get());
} catch (Exception e) {
future.fail(e);
}
}).onComplete(ar -> result.set(ar.result())
vertx.executeBlocking(
() -> {
HttpClientCommand command = new HttpClientCommand(client, "/");
return command.queue().get();
}).onComplete(ar -> result.set(ar.result())
);
});

Expand All @@ -136,11 +132,11 @@ public void testFailure() throws Exception {

// Blocking call..., need to run in an executeBlocking

vertx.<String>executeBlocking(
future -> {
HttpClientCommand command = new HttpClientCommand(client, "/error");
future.complete(command.execute());
}).onComplete(ar -> result.set(ar.result())
vertx.executeBlocking(
() -> {
HttpClientCommand command = new HttpClientCommand(client, "/error");
return command.execute();
}).onComplete(ar -> result.set(ar.result())
);
});

Expand All @@ -151,15 +147,11 @@ public void testFailure() throws Exception {
vertx.runOnContext(v -> {

// Blocking call..., need to run in an executeBlocking
vertx.<String>executeBlocking(
future -> {
HttpClientCommand command = new HttpClientCommand(client, "/error");
try {
future.complete(command.queue().get());
} catch (Exception e) {
future.fail(e);
}
}).onComplete(ar -> result.set(ar.result())
vertx.executeBlocking(
() -> {
HttpClientCommand command = new HttpClientCommand(client, "/error");
return command.queue().get();
}).onComplete(ar -> result.set(ar.result())
);
});

Expand Down

0 comments on commit 9a99a8a

Please sign in to comment.