Comments (6)
withDelay
should always work, even when manually operating the CircuitBreaker. State transitions occur when CircuitBreaker.allowsExecution
is called. If the delay has been exceeded since the circuit breaker has been in that state, then a transition will happen. Here's a bit of code that demonstrates:
public void test() throws Throwable {
CircuitBreaker breaker = new CircuitBreaker().withDelay(500, TimeUnit.MILLISECONDS);
breaker.open();
breaker.allowsExecution();
Thread.sleep(400);
assertTrue(breaker.isOpen());
Thread.sleep(150);
breaker.allowsExecution();
assertTrue(breaker.isHalfOpen());
}
Are you seeing something else?
from failsafe.
Ups, I didn't use this method, it's pretty unobvious that this method triggers state changing and getState doesn't. Maybe additional javadocs for getState() that if you want state to be updated - you should trigger allowsExecution()
before in case of standalone usage? Thanks for your help anyway.
from failsafe.
No problem. getState()
triggering a transition check is not a bad idea. Standalone usage is a bit more of a niche use case, but I want it to make sense.
from failsafe.
@Spikhalskiy What would your ideal API/usage look like? The example in the docs uses allowsExecution
, but maybe that doesn't make sense for all use cases...
from failsafe.
@jhalterman I already can't adopt canonical failsafe API to my project, because we have some different requirements like... in half_open state we don't want to allow any concurrent executions, we want to allow only one execution for health check and only after success of this one execution allow concurrency for this service. But CircuitBreaker alone is very fine for me.
Give me some time, maybe I would back with few pull requests and proposals. Thank you for response.
from failsafe.
@Spikhalskiy Your comments are welcome and appreciated.
I have thought about supporting limited concurrency in half-open state (see #44), but haven't heard much from users on this so it wasn't a priority. Right now max concurrency is determined by the success and failure thresholds you set:
So you could set .withSuccessThreshold(1)
and it sounds like that should work for your use case. The problem is that right now, tracking currentExecutions isn't really supported for standalone usage. For internal usage via the Failsafe
class, failsafe calls CircuitBreaker.before, so something like that would need to be exposed for standalone usage to inform the breaker that an execution is about to be performed.
from failsafe.
Related Issues (20)
- Why does CheckedPredicate exist? HOT 2
- Also add note about default maxRetries of 3 to maxDuration section of the documentation HOT 7
- Bulkhead policy may drop requests when maxWaitTime is specified HOT 8
- Guidance around CheckedPredicate HOT 2
- Time based error limiter policy
- [Question]Can withBackoff and withDelay be used at the same time? HOT 2
- RetryPolicy handleIf not working with DynamoDbException in predicate HOT 4
- Having a context object in the run(...) and get(...) methods HOT 7
- dev.failsafe.Functions.* do not propagate toString to the wrapped object
- [Question] Is it possible to have multiple Fallback policies in one Failsafe executor? HOT 4
- [question] how to use failsafe with kotlin
- Feature Request: Integrate / add support for Lunar Proxy (backend policy) HOT 1
- Why recommend CircuitBreaker before Retry? HOT 1
- CircuitBreaker stays in OPEN even after DELAY time HOT 1
- Nested retries, how to prevent duplicate retrying? HOT 5
- FailsafeExecutor.compose and .with(Executor) have surprising composition behavior
- Provide BOM with all failsafe artifacts for better dependency management
- Failsafe okhttp integration causes issues with BearerAuth and outdated tokens
- CircuitBreakerBuilder withSuccessThreshold documentation whoopsy HOT 1
- [Question] Is it possible to override the "maxRetries" and "delay" of retry policy at runtime? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from failsafe.