forked from vert-x3/vertx-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add staging repository to maven and gradle builds
- Loading branch information
1 parent
72f915b
commit e90c905
Showing
118 changed files
with
551 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
circuit-breaker-examples/src/main/kotlin/io/vertx/example/circuit/breaker/Client.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.vertx.example.circuit.breaker | ||
|
||
import io.vertx.circuitbreaker.CircuitBreaker | ||
import io.vertx.circuitbreaker.CircuitBreakerOptions | ||
import io.vertx.kotlin.circuitbreaker.* | ||
|
||
class Client : io.vertx.core.AbstractVerticle() { | ||
override fun start() { | ||
var options = CircuitBreakerOptions( | ||
maxFailures = 5, | ||
timeout = 5000, | ||
fallbackOnFailure = true) | ||
|
||
var breaker = CircuitBreaker.create("my-circuit-breaker", vertx, options).openHandler({ v -> | ||
println("Circuit opened") | ||
}).closeHandler({ v -> | ||
println("Circuit closed") | ||
}) | ||
|
||
var result = breaker.executeWithFallback({ future -> | ||
vertx.createHttpClient().getNow(8080, "localhost", "/", { response -> | ||
if (response.statusCode() != 200) { | ||
future.fail("HTTP error") | ||
} else { | ||
response.exceptionHandler({ future.fail(it) }).bodyHandler({ buffer -> | ||
future.complete(buffer.toString()) | ||
}) | ||
} | ||
}) | ||
}, { v -> | ||
// Executed when the circuit is opened | ||
return "Hello (fallback)" | ||
}) | ||
|
||
result.setHandler({ ar -> | ||
// Do something with the result | ||
println("Result: ${ar.result()}") | ||
}) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
circuit-breaker-examples/src/main/kotlin/io/vertx/example/circuit/breaker/Server.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.vertx.example.circuit.breaker | ||
|
||
|
||
class Server : io.vertx.core.AbstractVerticle() { | ||
override fun start() { | ||
vertx.createHttpServer().requestHandler({ req -> | ||
req.response().end("Bonjour") | ||
}).listen(8080) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.