package io.vertx.example.circuit.breaker;

import io.vertx.circuitbreaker.CircuitBreaker;
import io.vertx.circuitbreaker.CircuitBreakerOptions;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Launcher;
import io.vertx.core.buffer.Buffer;

/**
 * @author <a href="pahan.224@gmail.com">Pahan</a>
 */

public class Client extends AbstractVerticle {

  public static void main(String[] args) {
    Launcher.executeCommand("run", Client.class.getName());
  }

  @Override
  public void start() {
    CircuitBreakerOptions options = new CircuitBreakerOptions()
      .setMaxFailures(5)
      .setTimeout(5000)
      .setFallbackOnFailure(true);

    CircuitBreaker breaker =
      CircuitBreaker.create("my-circuit-breaker", vertx, options)
        .openHandler(v -> {
          System.out.println("Circuit opened");
        }).closeHandler(v -> {
        System.out.println("Circuit closed");
      });

    breaker.executeWithFallback(promise -> {
      vertx.createHttpClient().get(8080, "localhost", "/").compose(resp -> {
        if (resp.statusCode() != 200) {
          return Future.failedFuture("HTTP error");
        } else {
          return resp.body();
        }
      }).map(Buffer::toString).onComplete(promise);
    }, v -> {
      // Executed when the circuit is opened
      return "Hello (fallback)";
    }, ar -> {
      // Do something with the result
      System.out.println("Result: " + ar.result());
    });
  }
}

@@ -271,16 +271,54 @@
 .Buffer;
+%0Aimport io.vertx.core.http.HttpMethod;
 %0A%0A/**%0A *
@@ -1051,12 +1051,32 @@
 t().
-get(
+request(HttpMethod.GET, 
 8080
@@ -1103,16 +1103,59 @@
 compose(
+req -%3E %7B%0A        return req.send().compose(
 resp -%3E 
@@ -1152,24 +1152,26 @@
 e(resp -%3E %7B%0A
+  
         if (
@@ -1204,24 +1204,26 @@
 %7B%0A          
+ 
+ 
 return Futur
@@ -1260,16 +1260,18 @@
         
+  
 %7D else %7B
@@ -1273,32 +1273,34 @@
 lse %7B%0A          
+ 
+ 
 return resp.body
@@ -1305,28 +1305,8 @@
 dy()
-;%0A        %7D%0A      %7D)
 .map
@@ -1323,16 +1323,50 @@
 oString)
+;%0A          %7D%0A        %7D);%0A      %7D)
 .onCompl

Update circuit breakdance examples for HTTP client