Comments (9)
I get an error:
for implements RetryListener {
I never compiled my code so I'm afraid you will have to take it with a grain of salt. :)
why are these atomic?
Because Java closures can't modify variables outside of its scope (since they need to be final
). Using Atomic*
classes circumvents that restriction.
what does this mean retry.getNumerOfAttampts() == 1 ?
What type is retry
? Have you checked the JavaDoc for the method? See http://rholder.github.io/guava-retrying/javadoc/2.0.0/.
I mean, should I create new listener to each request?
I guess that really depends if you decide to keep any state in it or not. In my example above I store my state in RetryableRequest
. That way, it's totally fine to create a new temporary listener for every request.
each listener have a request member and thus i don't need thread safety (atomic boolean). no?
Like I said ☝️, the Atomic*
classes aren't really used for thread safety, but rather working around Java limitations.
from guava-retrying.
You might be able to keep track of that in a RetryListener
which you give to the RetryerBuilder
. Does that solve your issue?
from guava-retrying.
can you help with a code snipet? I'm not sure the code that calls the backoff mechanism can read the falg indicating a request was successful only after a retry?
from guava-retrying.
Let's take a step back. What is your use-case? Why do you want to flag the retry?
from guava-retrying.
I have a list of requests. I want to flag each response with "succeeded"(status 200) , "failed", "succeeded after retry"
from guava-retrying.
Something like this should probably get you started:
class RetryableRequest implements RetryListener<Boolean> {
private final Retryer retryer;
private final Request request;
private final AtomicBoolean succeeded = new AtomicBoolean();
private final AtomicBoolean retried = new AtomicBoolean();
public RetryableRequest(Request request) {
this.retryer = RetryerBuilder.withRetryListener(this).build();
this.request = request;
}
public void execute() {
retryer.call(new Callable<Boolean>() {
public Boolean call() {
request.execute();
// Here you modify `succeeded`.
}
});
}
public void onRetry(Attempt<Boolean> retry) {
if (!retry.hasResult())
retried.set(true);
}
public boolean executionWasRetried() {
return retried.get();
}
public boolean executionSucceeded() {
return succeeded.get();
}
}
from guava-retrying.
I get an error:
for implements RetryListener<Boolean> {
Error:(15, 48) java: type com.github.rholder.retry.RetryListener does not take parameters
from guava-retrying.
why are these atomic?
private final AtomicBoolean succeeded = new AtomicBoolean();
private final AtomicBoolean retried = new AtomicBoolean();
I mean, should I create new listener to each request?
each listener have a request member and thus i don't need thread safety (atomic boolean). no?
from guava-retrying.
what does this mean retry.getNumerOfAttampts() == 1
?
- The first try ever has been done?
e.g. http send and returned
Or
2) These has been a retry after the a failure (retry-predicate returned false)?
http send and returned failure, then we sent a retry already.
from guava-retrying.
Related Issues (20)
- Since this project has not been maintained for a long time, I fork this project and fix the problem
- Feature Request: remove final modifier from com.github.rholder.retry.Retryer
- Failed to collect dependencies at com.github.rholder:guava-retrying:jar:2.0.0 HOT 5
- Any interest in a Future's retryer? HOT 2
- The lib is crashing when used in Ratpack (guava-20.0rc1) HOT 4
- Retryer.call should not catch Errors like OOME
- Could I build the Retryer with different executors? HOT 3
- ./gradlew build on macOS Sierra with JDK 1.8 throwing a Java compile error HOT 3
- is there a way to make it log what it's doing? HOT 3
- Is there a way to do this on something that is not a callable? HOT 5
- artifact has a compile time dependency on jsr305
- RetryerBuilder having protected constructor HOT 2
- Project appears to be dead: it has been forked to rhuffman/re-retrying HOT 1
- Initial wait time in an exponential retry strategy. HOT 3
- When i should use Fibonacci WaitStrategy
- When I run demo , when successNum coming my process can not exit immediately
- WaitStrategies documentation should mention milliseconds
- The problem with 'AttemptTimeLimiters.fixedTimeLimit' HOT 2
- doubts about SimpleTimeLimiter has private Constructor,but FixedAttemptTimeLimit new it?
- Bug: StopStrategies&StopStrategies will throw unformatted message HOT 1
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 guava-retrying.