-
Notifications
You must be signed in to change notification settings - Fork 217
feat(scheduler): add support for attemptDeadline in onSchedule #1723
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
base: master
Are you sure you want to change the base?
Conversation
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.
Summary of Changes
Hello @Skyfury2651, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly improves the developer experience for Firebase Functions by integrating the attemptDeadline option directly into the onSchedule configuration. Previously, this setting required manual adjustment in the Google Cloud Console, but now it can be defined alongside other function parameters, streamlining deployment and configuration. The change primarily involves extending relevant interfaces and functions to properly handle and apply this new retry configuration option for both v1 and v2 Firebase Functions.
Highlights
- New Feature:
attemptDeadlineSupport: This pull request introduces support for theattemptDeadlineoption directly within theonScheduleconfiguration for Firebase Functions. This enhancement allows developers to specify the maximum duration for each job attempt programmatically, eliminating the need for manual configuration in the Google Cloud Console after deployment. - API Extension for Scheduler Options: The
attemptDeadlineproperty has been added to theScheduleRetryConfiginterface for v1 functions and theScheduleOptionsinterface for v2 functions. This provides a consistent and integrated way to manage retry behavior for scheduled functions. - Enhanced Test Coverage: Comprehensive test cases have been added and updated across
spec/runtime,spec/v1, andspec/v2directories to ensure that theattemptDeadlineoption is correctly processed, recognized, and applied when defining scheduled Firebase Functions.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request adds support for the attemptDeadline option for scheduled functions, which is a great addition. The changes are well-implemented across the different layers of the codebase, including type definitions, v1 and v2 function configurations, and tests.
I've found one area in src/v2/providers/scheduler.ts where the logic can be simplified for better maintainability. My suggestion is to refactor the getOpts function to be more concise and avoid unnecessary checks.
Overall, this is a solid contribution. Once the suggested change is addressed, this should be ready to merge.
src/v2/providers/scheduler.ts
Outdated
| const retryConfig: any = { | ||
| retryCount: args.retryCount, | ||
| maxRetrySeconds: args.maxRetrySeconds, | ||
| minBackoffSeconds: args.minBackoffSeconds, | ||
| maxBackoffSeconds: args.maxBackoffSeconds, | ||
| maxDoublings: args.maxDoublings, | ||
| }; | ||
|
|
||
| if (args.attemptDeadline !== undefined) { | ||
| retryConfig.attemptDeadline = args.attemptDeadline; | ||
| } | ||
|
|
||
| return { | ||
| schedule: args.schedule, | ||
| timeZone: args.timeZone, | ||
| retryConfig: { | ||
| retryCount: args.retryCount, | ||
| maxRetrySeconds: args.maxRetrySeconds, | ||
| minBackoffSeconds: args.minBackoffSeconds, | ||
| maxBackoffSeconds: args.maxBackoffSeconds, | ||
| maxDoublings: args.maxDoublings, | ||
| }, | ||
| retryConfig, | ||
| opts: args as options.GlobalOptions, | ||
| }; |
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.
The logic for constructing retryConfig can be simplified. The current implementation uses a temporary variable with type any and an if condition to add attemptDeadline.
Since copyIfPresent is used later in onSchedule and it already handles undefined values, you can simplify this by directly constructing the retryConfig object in the return statement. This will make the code more concise and improve type safety by avoiding any.
return {
schedule: args.schedule,
timeZone: args.timeZone,
retryConfig: {
retryCount: args.retryCount,
maxRetrySeconds: args.maxRetrySeconds,
minBackoffSeconds: args.minBackoffSeconds,
maxBackoffSeconds: args.maxBackoffSeconds,
maxDoublings: args.maxDoublings,
attemptDeadline: args.attemptDeadline,
},
opts: args as options.GlobalOptions,
};|
This is my first contribution to this project 🙏 |
|
Waiting for action on this PR : |
Description
Add support for the
attemptDeadlineoption in Cloud Scheduler when using Firebase Functions.Previously, the
attemptDeadlinevalue had to be configured manually in the Google Cloud Console after deploying a scheduled function. With this change, developers can specifyattemptDeadlinedirectly in theonScheduleoptions ( or atleast i think so ), ensuring the configuration is applied automatically during deployment.Code sample