Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add randomExpression to backoff annotation #266

Merged

Conversation

Deviad
Copy link

@Deviad Deviad commented Feb 14, 2022

No description provided.

@pivotal-cla
Copy link

@Deviad Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@Deviad Thank you for signing the Contributor License Agreement!

Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. It looks ok to me, but I am curious as to why this needs to be an expression; it seems to me this would be set by the developer and not need to be evaluated during initialization; just interested in the use case.

@Deviad
Copy link
Author

Deviad commented Feb 14, 2022

    @Retryable(include = {Exception.class}, backoff = @Backoff(
            delayExpression = "#{new Long(${property.delay})}",
            multiplierExpression = "#{new Long(${property.multiplier})}",
            maxDelayExpression = "#{new Long(${property.maxDelay})}",
            randomExpression = "#{new Boolean(${property.random})}",
    ))
    public FancyDTO somethingFancy(final String foobar) {
    }

Instead of creating a feature flag to activate/deactivate it, and use @ConditionalOnProperty, which would cause code duplication (as I would need to copy paste an entire class), I can simply activate/deactivate it with a property set accordingly for each environment (and avoid code duplication) where I want to test it and make a note of the outcome.
E.g.: you wanna push the changes initially to stage but leave prod unchanged.

This is available already here:
https://reflectoring.io/retry-with-springboot-resilience4j/

I managed to reproduce that with SPEL so that props are fetched from properties files.

@garyrussell
Copy link
Contributor

garyrussell commented Feb 14, 2022

Thanks; I understand what it does, and how it does it; my question is why someone would want to do it?

i.e. why would you want it different in dev Vs. prod?

@Deviad
Copy link
Author

Deviad commented Feb 14, 2022

Cos we can can monitor the effects of the change as I said (in terms of throughput, back-pressure, etc.) and push it forward if it satisfies our needs (for a particular endpoint).

@garyrussell garyrussell merged commit 3ad812a into spring-projects:main Feb 16, 2022
@snicoll snicoll added this to the 1.3.2 milestone Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants