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

Recommend fault tolerance instead of max-retries #177

Closed
wants to merge 1 commit into from
Closed

Recommend fault tolerance instead of max-retries #177

wants to merge 1 commit into from

Conversation

geoand
Copy link
Collaborator

@geoand geoand commented Dec 20, 2023

No description provided.

@geoand geoand requested a review from a team as a code owner December 20, 2023 15:36
@edeandrea
Copy link
Collaborator

I actually prefer the property configuration of the retries. It allows for customizing the retry logic per deployment (dev mode vs unit test vs integration test vs prod...)

@edeandrea
Copy link
Collaborator

edeandrea commented Dec 20, 2023

What about with the timeouts as well? There are default timeouts set on the underlying Langchain4J calls that would need to be translated to use SmallRye Fault tolerance annotations?

Now you'll also have competing priorities. I'd prefer using the framework-provided config options rather than fault tolerance annotations.

If you don't want users to use the config options, then don't expose them.

But honestly, I like the ability to configure retries/timeouts via config rather than annotations.

@geoand
Copy link
Collaborator Author

geoand commented Dec 20, 2023

I actually prefer the property configuration of the retries. It allows for customizing the retry logic per deployment (dev mode vs unit test vs integration test vs prod...)

You can provide a configuration property in the Smallrye config annotations, right?

@edeandrea
Copy link
Collaborator

You can provide a configuration property in the Smallrye config annotations, right?

You can?

@geoand
Copy link
Collaborator Author

geoand commented Dec 20, 2023

I think so, but I might be misremembering

@edeandrea
Copy link
Collaborator

edeandrea commented Dec 20, 2023

According to https://quarkus.io/guides/smallrye-fault-tolerance it looks like you can for retries, but its kinda ugly. The configuration key has to contain both the fully-qualified class name & method name...

Even the SmallRye docs don't mention that you can do it for timeouts...

package org.acme;

import org.eclipse.microprofile.faulttolerance.Retry;
...

public class CoffeeResource {
    ...
    @GET
    @Retry(maxRetries = 4)
    @Timeout(value = 4, unit = ChronoUnit.SECONDS)
    public List<Coffee> coffees() {
        
    }
    ...
}

and then

org.acme.CoffeeResource/coffees/Retry/maxRetries=6

That being said, I think enforcing timeouts one way but retries another is clunky to be honest.

@geoand
Copy link
Collaborator Author

geoand commented Dec 20, 2023

Hm, @Ladicek would know for sure if we have better config property resolution support in Quarkus

@Ladicek
Copy link

Ladicek commented Dec 20, 2023

There's a feature request for better config properties for Fault Tolerance, but nothing specific has been done about that yet. The main issue is that we don't really have an identifier we could use (akin to e.g. RestClient's configKey).

And for the record, even though we only show retries in the documentation of Fault Tolerance configuration, the exact same thing applies to all Fault Tolerance annotations, even those that come from SmallRye.

@geoand
Copy link
Collaborator Author

geoand commented Dec 20, 2023

Thanks for the information

@edeandrea
Copy link
Collaborator

And for the record, even though we only show retries in the documentation of Fault Tolerance configuration, the exact same thing applies to all Fault Tolerance annotations, even those that come from SmallRye.

Say I have

@Timeout(value = 4, unit = ChronoUnit.SECONDS)

and via config I wanted to change value=6 and unit = ChronoUnit.MILLIS - how would I do that via properties?

org.acme.CoffeeResource/coffees/Timeout/value=6
org.acme.CoffeeResource/coffees/Timeout/unit=?????

@Ladicek
Copy link

Ladicek commented Dec 20, 2023

ChronoUnit is an enum, so whatever works for enums elsewhere, works here as well. MILLIS should work and maybe even millis (not sure about that).

@edeandrea
Copy link
Collaborator

So

org.acme.CoffeeResource/coffees/Timeout/value=6
org.acme.CoffeeResource/coffees/Timeout/unit=MILLIS

should work? Or does ChronoUnit. need to be there?

org.acme.CoffeeResource/coffees/Timeout/value=6
org.acme.CoffeeResource/coffees/Timeout/unit=ChronoUnit.MILLIS

@Ladicek
Copy link

Ladicek commented Dec 20, 2023

So

org.acme.CoffeeResource/coffees/Timeout/value=6
org.acme.CoffeeResource/coffees/Timeout/unit=MILLIS

should work?

Absolutely.

Or does ChronoUnit. need to be there?

org.acme.CoffeeResource/coffees/Timeout/value=6
org.acme.CoffeeResource/coffees/Timeout/unit=ChronoUnit.MILLIS

No.

@jmartisk
Copy link
Collaborator

@geoand, can we close this now that we have #507 in?

@geoand
Copy link
Collaborator Author

geoand commented May 21, 2024

Good point!

@geoand geoand closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants