Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Scheduler] events? #49803

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

Closed
kbond opened this issue Mar 25, 2023 · 3 comments
Closed

[Scheduler] events? #49803

kbond opened this issue Mar 25, 2023 · 3 comments

Comments

@kbond
Copy link
Member

kbond commented Mar 25, 2023

Description

I know when using the scheduler with messenger, you can use worker message events but I wonder if we should add scheduler-specific events? The stand-alone Scheduler could benefit.

Example

I think it could be nice DX to define events when defining your schedule:

public function getSchedule(): Schedule
{
    return (new Schedule())
        ->add(RecurringMessage::cron('* * * * *', new DoSomething()))
        ->before(function(PreRunEvent $event) {})
        ->after(function(PostRunEvent $event) {})
        ->onFailure(function(FailureEvent $event) {})

        // maybe some out of the box helpers
        ->emailOnFailure(...) // uses symfony/mailer
        ->notifyOnFailure(...) // uses symfony/notifier
        ->pingBefore('https://some-uptime-service.com/oihjnjf8sd')
        ->pingAfter('https://some-uptime-service.com/jdhdud832hd')
        ->pingOnFailure('https://some-uptime-service.com/8978df7d')
    ;
}
@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@kbond
Copy link
Member Author

kbond commented Sep 26, 2023

Closing as I no longer see a need for this now that the ScheduledStamp has more detail.

If anyone has a specific use-case that can't be solved with standard messenger events (ping @alli83), feel free to re-open.

@kbond kbond closed this as completed Sep 26, 2023
@derrabus derrabus closed this as not planned Won't fix, can't repro, duplicate, stale Sep 26, 2023
@alli83
Copy link
Contributor

alli83 commented Oct 1, 2023

Closing as I no longer see a need for this now that the ScheduledStamp has more detail.

If anyone has a specific use-case that can't be solved with standard messenger events (ping @alli83), feel free to re-open.

Thank you @kbond I'll reopen this issue and I'll ping you as soon as I open my PR :)

fabpot added a commit that referenced this issue Oct 16, 2023
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       | MIT

Based on #49803 `@kbond`  and taking into account #51553

The 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 itself

This PR would complement `@Jeroeny` #51553 PR by enabling action via events.

Commits
-------

20fd21a [Scheduler] add PRE_RUN and POST_RUN events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants