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

fix(pgboss): Add JobExpiryHours for every job #352

Merged
merged 1 commit into from
Mar 22, 2025
Merged

Conversation

kalpadhwaryu
Copy link
Contributor

Description

Add JobExpiryHours for every job.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @kalpadhwaryu, 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!

Summary of Changes

This pull request introduces a JobExpiryHours configuration parameter to set an expiration time for background jobs. This ensures that jobs are automatically removed after a specified duration, preventing the queue from growing indefinitely. The JobExpiryHours parameter is added to the configuration and then used when enqueueing jobs using pg-boss in server/api/admin.ts, server/api/oauth.ts, and server/queue/index.ts.

Highlights

  • Configuration: Introduces JobExpiryHours in server/config.ts to define the default job expiration time.
  • Job Enqueueing: Modifies job enqueueing in server/api/admin.ts and server/api/oauth.ts to include the expireInHours option when sending jobs to the queue.
  • Scheduled Jobs: Updates scheduled jobs in server/queue/index.ts to include the expireInHours option, ensuring that recurring jobs also have an expiration time.

Changelog

Click here to see the changelog
  • server/api/admin.ts
    • Imported JobExpiryHours from config.
    • Added expireInHours option when enqueueing jobs.
  • server/api/oauth.ts
    • Imported JobExpiryHours from config.
    • Added expireInHours option when enqueueing jobs.
  • server/config.ts
    • Added JobExpiryHours configuration parameter with a default value of 23.
  • server/queue/index.ts
    • Imported JobExpiryHours from config.
    • Added expireInHours option to scheduled jobs.
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 is currently in preview and 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 to provide feedback.

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.


Trivia time!

What is the maximum number of hours a PostgreSQL interval can represent?

Click here for the answer
PostgreSQL intervals can represent a wide range of time, and there isn't a hard-coded maximum number of hours. The limits are determined by the underlying data types used to store the interval components (years, months, days, hours, etc.).

Footnotes

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a JobExpiryHours configuration to set the expiration time for jobs in the pg-boss queue. This enhancement ensures that jobs are automatically removed after a specified duration, preventing the queue from growing indefinitely. The changes look good overall, but I have a few suggestions to improve clarity and maintainability.

Summary of Findings

  • Configuration Value Consistency: The JobExpiryHours configuration value is defined in server/config.ts and also declared in server/queue/index.ts. It would be better to rely on the single source of truth defined in server/config.ts to avoid potential inconsistencies.
  • Job Expiry Hours Value: The JobExpiryHours is currently set to 23 hours. Consider whether this value is appropriate for all job types, or if some jobs might benefit from a shorter or longer expiry time. If different job types require different expiry times, consider making the expiry time configurable per job type.

Merge Readiness

The pull request introduces a useful feature for managing job expiration in the pg-boss queue. However, I recommend addressing the configuration value consistency issue and considering the appropriateness of the default expiry time for all job types before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity comments should be addressed before merging.

Comment on lines 18 to +19
const Logger = getLogger(Subsystem.Queue)
const JobExpiryHours = config.JobExpiryHours

Choose a reason for hiding this comment

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

high

The JobExpiryHours constant is declared here, but it's already defined in config.ts. To avoid duplication and potential inconsistencies, it's better to directly use config.JobExpiryHours where needed instead of declaring a new constant.

Consider removing this line and directly referencing config.JobExpiryHours in the schedule options.

@zereraz zereraz merged commit 4a1511e into main Mar 22, 2025
3 checks passed
@zereraz zereraz deleted the add-jobExpiry-const branch March 22, 2025 07:05
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.

2 participants