Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces a cronPattern parameter to CronRunnableEntry and CronEntryModule, enabling clients to specify a custom cron pattern directly when registering a runnable, rather than relying solely on annotations. This change maintains backward compatibility by setting cronPattern to null by default, preserving existing behavior. ### Key Changes - CronRunnableEntry Update: Added an optional `cronPattern` property with a default value of `null`. This allows clients to specify a cron pattern directly when creating the entry. - CronEntryModule Update: Modified `CronEntryModule` to accept an optional `cronPattern` parameter in its factory methods, enabling users to provide a cron pattern when registering a runnable. - `CronService::startUp` Logic: Enhanced startUp to prioritize the cronPattern from `CronRunnableEntry`. If no pattern is specified, the service falls back to the `@CronPattern` annotation on the runnable class. This update improves flexibility, allowing clients to override the annotation pattern with a custom pattern if needed. ### Compatibility - Backward Compatibility: Existing clients that rely on annotations for cron scheduling will continue to work without modification, as cronPattern defaults to null. - Enhanced Flexibility: Clients now have the option to specify a custom cron pattern directly, without changing the underlying annotations. ### Use Cases This enhancement is particularly valuable for cron jobs that need flexible scheduling across different contexts. For instance, a database cleanup job may require frequent execution for services with high insertion rates, ensuring timely data management and optimal performance. Conversely, for services with low insertion rates, the job can be scheduled less frequently, conserving resources while still meeting maintenance needs. ### Additional Notes - Updated comments in `CronService::startUp` to clarify the precedence between cronPattern in `CronRunnableEntry` and the @CronPattern annotation. - This change is additive and introduces no breaking changes for existing clients. GitOrigin-RevId: 838c362bd0c589486d3dee12dd24455c40d0940f
- Loading branch information