Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Scheduler] Allow modifying the schedule at runtime and recalculate heap#51553
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Interesting, is this a companion PR for#51542? |
@kbond they don't depend on each other. But when both of them are merged, it enables a lot of capabilities for the Scheduler. |
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.
Can you add some usage example in the PR description?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@@ -10,6 +10,7 @@ CHANGELOG | |||
* Add `AbstractTriggerDecorator` | |||
* Make `ScheduledStamp` "send-able" | |||
* Add `ScheduledStamp` to `RedispatchMessage` | |||
* Allow modifying the Schedule at runtime |
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.
* Allow modifyingtheSchedule at runtime | |
* Allow modifying Schedule instances at runtime |
Thank you@Jeroeny. |
This PR was merged into the 6.4 branch.Discussion----------[Scheduler] pre_run and post_run events| Q | A| ------------- | ---| Branch? | 6.4| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets |#49803 (comment)| License | MITBased on#49803 `@kbond` and taking into account#51553The aim of this PR is to be able to act on the accumulated messages 'if something happens' and to be able to recalculate the heap via events (currently pre_run and post_run).The aim is to have access to- the the schedule and therefore add/cancel a certain type of message.- MessageContexte (e.g. access the id)- The message itselfThis PR would complement `@Jeroeny`#51553 PR by enabling action via events.Commits-------20fd21a [Scheduler] add PRE_RUN and POST_RUN events
Sophikitis commentedFeb 17, 2024
Hi ! Do you have any examples of use? And as far as I understand, there's no documentation for this feature. |
Hanmac commentedApr 16, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@fabpot I'm also looking for an example, currently i uses this Doctrine Query to build the Schedule publicfunctiongetSchedule():Schedule {$result =newSchedule();$repo =$this->manager->getRepository(Terminal::class);$q =$repo->createQueryBuilder('t');$q->where('t.status = true AND t.automatic = true');foreach ($q->getQuery()->getResult()as$r) {/** * @var Terminal $r */$result->add(RecurringMessage::cron($r->getCronExpr(),newKassenschlussTask($r->getId()),$this->timezoneDetector->getTimezone()) ); }return$result; } because each object might have its own CronExpr, each of them needs its own RecurringMessage and how do i handle if they get disabled? |
@Sophikitis while maybe not the best way, i found $cacheItem =$this->restartSignalCachePool->getItem(StopWorkerOnRestartSignalListener::RESTART_REQUESTED_TIMESTAMP_KEY);$cacheItem->set(microtime(true));$this->restartSignalCachePool->save($cacheItem); i used |
Uh oh!
There was an error while loading.Please reload this page.
Schedules are created statically by a ScheduleProviderInterface. This is nice if you have a small app with some predetermined scheduled actions. But if you want to schedule business logic dynamically, e.g. have admins Crud a schedule in the DB, then the schedule needs to be updateable at runtime. This also allows for the app to re-add schedules that have returned
null
as nextRunDate in the past (making them unscheduled) and to remove schedules.Usage example: reading the schedule from a DB repository, adding messages based on an custom event:
Or in the context of Messenger, if some periodic batch task has no more work to do, the recurring message can be removed: