-
Notifications
You must be signed in to change notification settings - Fork 45
Add Retry annotation #139
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 Retry annotation #139
Conversation
src/main/java/com/microsoft/azure/functions/annotation/FixedDelayRetry.java
Outdated
Show resolved
Hide resolved
No need to block on webjobs sdk typo fix as this PR is not affected by it. |
Shouldn't we add annotation that matches retry options in host.json : https://github.com/Azure/azure-functions-host/blob/dev/sample/NodeRetry/host.json#L3-L7 ? Also, this might need changes in maven plugin to produce right Method level annotations are required to produce retry section in |
@pragnagopa This is is really good point, Thank you so much |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the java-library version as part of this PR. Once the changes are in , publish SNAPSHOT version so that mvn plugin can be updated.
Hi @pragnagopa |
FunctionTimeout is at host.json as well. Would be good to understand how this is handled in mvn |
@pragnagopa |
Hi @pragnagopa , @apawast and @jeffhollan I have a question. I talked with @Flanker32 and he has an idea. Currently, I separate the annotation into too. What do you think the idea? Hi @Flanker32 If I miss some context, feel free to add the context or correct what I wrote. |
@TsuyoshiUshio Thanks a lot for your efforts, really exciting feature! Here is my thoughts for the annotation, as @TsuyoshiUshio said, it seems one Retry annotation should be enough for both the cases, here is an example public @interface Retry {
RetryStrategy strategy();
int maxRetryCount();
int delayInterval();
int maximumInterval();
static enum RetryStrategy {
EXPONENTIAL, FIXED;
}
} By the way could we pass the retry meta data to trigger? So that users may know how many times the trigger failed and send some telemetry based on this data. |
maven plugin will not modify the |
For the For instance, if set |
Yes, Annotation has to match : #139 (comment) Thanks for clarifying this
@TsuyoshiUshio / @amamounelsayed - I believe we never supported class level annotations. Please open a separate issue. If more users ask for it then we can figure out right design. Please scope this PR to adding method level annotations only.
No need to add validation in the tooling as the runtime will show proper validation errors at runtime. Same is true for other questions you asked. Validation is handled by the runtime so no need to duplicate validation logic in the tooling. |
Currently we do not have this. We are tracking the feature here: Azure/azure-webjobs-sdk#2595 |
I'm ok for the @Flanker32 idea. What do you think? @jeffhollan or @apawast ? #139 (comment) |
@TsuyoshiUshio - just to clarify , the annotation needed is the |
Hi @pragnagopa Thanks. I also tested from my side by changing function.json manually and it works. So that the annotation definition on the Java side doesn't matter. |
This is the design for all out-of-proc languages. In Java annotation is used to generate function.json so that users manually do not have to edit |
Thank you for sharing the context of the design! So that we can design annotation as we like. |
Hi @Flanker32 @amamounelsayed @pragnagopa @apawast
I'd like to take your idea. I'll update this PR soon. |
Hi @Flanker32 Hi @pragnagopa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added minor comment. Please wait for ACK from @amamounelsayed . Also, open issue in mvn plugin and link it here to ensure we have a track updates on the mvn plugin before publishing a version without -SNAPSHOT
Hi @Flanker32 Do you know why this CI fails happens? it is cloning the maven plugin and cannot find azure-auth-helper. Do I need package repository? https://github.com/microsoft/azure-maven-plugins/blob/develop/azure-maven-plugin-lib/pom.xml#L116 |
* The minimum delay interval. | ||
* @return The minimum retry delay. | ||
*/ | ||
String minimumInterval() default ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we use integer here and set the interval in second directly? which may be more clear and no need to care about the format. Otherwise, do we support time string like 00:00:120
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the format is 00:00:10
. https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages?tabs=java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats a good point! minimumInterval, maximumInterval and delayInterval get converted to type TimeSpan , is there an equivalent in Java?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if converting Duration
to string will give us the format hh:mm:ss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do it. There is an api to fetch it as second. However, I'm not sure Duration
is good fit for the annotation. Probably String (as is) or int (second) might be a good fit for it. (I just reply the TimeSpan equivalent) https://www.dariawan.com/tutorials/java/java-time-duration-tutorial-examples/
Hi @Flanker32 Which would you want to prefer? If you choose int, you need to format String. If you use String, no need to convert it since it is the format of function.json
IMO, String might be better. the reason is, Functions Host currently support String with that format. In the future, if people add expression on the String on the functions host side, we need to do breaking change. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for going back and forth on this. Thinking about this more, initial commit you had probably makes sense as the scope is method level only and having separate annotations eliminates guess work for users on what values to provide for each strategy.
This would be similar to what webjobs SDK exposes but mvn would have to generate retry
section in function.json
src/main/java/com/microsoft/azure/functions/annotation/RetryStrategy.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/azure/functions/annotation/RetryStrategy.java
Outdated
Show resolved
Hide resolved
* The minimum delay interval. | ||
* @return The minimum retry delay. | ||
*/ | ||
String minimumInterval() default ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if converting Duration
to string will give us the format hh:mm:ss
src/main/java/com/microsoft/azure/functions/annotation/Retry.java
Outdated
Show resolved
Hide resolved
Hi @Flanker32
In this case, the retry duration is 10s. There is no exception. If the retry duration reach to the maximum interval, it keeps the maximum interval. |
src/main/java/com/microsoft/azure/functions/annotation/FixedDelayRetry.java
Show resolved
Hide resolved
src/main/java/com/microsoft/azure/functions/annotation/ExponentialBackoffRetry.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signing off again :) thank you!
Create a PR for retry annotation to discuss the spec. The annotation requires maven plugin's change.
I'll update this PR to spot the correct spec once I figure out.
Current Version of the C# implementation has Typo. I correct the spelling on Java. The C# will fix it soon.
Azure/azure-webjobs-sdk#2637
What should we generate from this annotation?
On the maven plugin side, we need to generate retry strategy part. These are examples.
@Flanker32 Could you have a look and can we start discussion for the change the maven plugin side?
Exponential Backoff
function.json
Fixed Delay
It requires Microsoft.Azure.WebJobs 3.0.23 However, the functions host already release it at this version.
https://github.com/Azure/azure-functions-host/releases/tag/v3.0.14785
For the CoreTools that is used by Maven Plugin:
I tested with this version. It works.