Skip to content

Instantly share code, notes, and snippets.

@ashkrit
Created August 11, 2020 03:04
Show Gist options
  • Save ashkrit/98f6ba37287593ae0b9fb9949ed68efc to your computer and use it in GitHub Desktop.
Save ashkrit/98f6ba37287593ae0b9fb9949ed68efc to your computer and use it in GitHub Desktop.
machine("Circuit Breaker", machine -> {
machine.startWith("OPEN");
machine.at("OPEN", rule -> {
rule.when("connect", failOp, "OPEN", "CLOSED");
});
machine.at("CLOSED", rule -> {
rule.when("connect", s -> {
}, "CLOSED");
rule.when("re-connect", s -> {
}, "HALF-OPEN");
});
machine.at("HALF-OPEN", rule -> {
rule.when("connect", s -> {
}, "CLOSED");
rule.when("re-open", s -> {
}, "OPEN");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment