-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Scheduler] add RecurringMessage::getId()
and prevent duplicates
#49838
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
Conversation
RecurringMessage::getId()
and prevent duplicatesRecurringMessage::getId()
and prevent duplicates
This change breaks the current test suite for scheduler. I'd like to get some feedback or alternative ideas before going further. Some context on my requirement for this: In my app, I have an admin GUI that lists all available scheduled tasks. User's can drill into each task (hence the need for a unique ID) and see a run history which includes memory usage and duration. The schedule name and ID on the There's likely other methods I can use to achieve this same system with symfony/scheduler so I'm not dead set on this being added. |
I've played a little with this. I could have my own custom logic to generate an identifier for a But I think I'd need the Basically, I think we need more context added to the |
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.
Having more information in the stamp does not look good as the component should work without using Messenger.
a14f2c7
to
ee23cba
Compare
Can save for a followup PR but I was thinking to change In the stand-alone |
Correctly I understand that now I can not use the same messages with the different arguments? ->add(RM::cron('*/6 * * * *', new Class1('aaa')))
->add(RM::cron('*/7 * * * *', new Class1('bbb')))
->add(RM::cron('*/7 * * * *', new Class1('ccc'))); In this case I got an error |
|
Not sure that will be good. it means that we will not be able to use two the same tasks if their cron trigger is same. Maybe more simple use iterable id if need to debug or execute the specific tasks manually, like this
|
In that case, yes, you'd need to make your message stringable.
Indeed, that could be an option. I'd like to track runs in the db so those id's changing whenever a schedule is updated wouldn't be desired. However, if the |
…e` (kbond) This PR was merged into the 6.3 branch. Discussion ---------- [Scheduler] have `TriggerInterface` extend `\Stringable` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | todo Helps with the output of `debug:schedule` and with #49838. Commits ------- 60dfc7f [Scheduler] have `TriggerInterface` extend `\Stringable`
ef446f0
to
5e03491
Compare
Rebased, refactored and added the ID to To address this concern, I now cast the message to a string if stringable, if not, serialize it, if it can't be serialized, ignore. That example now works without needing |
a3d4e57
to
2473d1f
Compare
@kbond Can you rebase and have a look at the failing tests? |
2473d1f
to
7e9a3ba
Compare
Done. |
Thank you @kbond. |
This could allow running specific scheduled tasks manually (via CLI or GUI).