-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Scheduler] add dependency on symfony/messenger #50096
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
public function __construct( | ||
public readonly ?string $name, | ||
public readonly TriggerInterface $trigger, | ||
public readonly \DateTimeImmutable $runAt, |
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.
Maybe we need a better name? This might not be the true run date (if the scheduler is catching up). Maybe $expectedRunAt
?
/cc @tucksaun
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.
expectedRunAt
sounds indeed better than runAt
.
Other suggestions:
scheduledAt
triggeredAt
(to keep the idea of the trigger)
@kbond On the one hand, it simplifies adding features. On the other hand, I'm afraid of lacking incapsulation and spreading internal details, which complicate future extension. |
Ok, I understand your concern, what about the following ideas:
I'm very open to other ideas! |
I might have something by mixing your approach and the one in #50085: we could imagine an intermediary class, not bound to Messenger, yield from the generator. See a draft here: https://github.com/symfony/symfony/compare/6.3...tucksaun:symfony:scheduler/generator-context?expand=1 |
Nice (simple) approach! You chose not to add the next run timestamp? (I don't have a strong opinion on this as it can be retrieved from the trigger). What do you think about including the schedule name? This is important context for me. Should it be added to the |
I didn't think about it tbh, I just wanted to draft quickly if this could be a way to do things or not.
In fact, I started to pick your change but then I was confused: should it go into the schedule or the generator? 🤔 |
I think it can't hurt to add. This will provide the expected next run time which may or may not match
I say open a PR - I like your approach better than this one. @upyx, what do you think?
I've struggled with this myself. The Schedule object itself doesn't have access to it's name. This is configured with the Since |
It is, and marked with the schedule transport name ( For some context, I'm working on a generic messenger-monitor bundle that has scheduler support. This is why I want all this context. In this bundle, a "monitored message" has |
Close in favor of #49792 |
…ing context (tucksaun) This PR was merged into the 6.3 branch. Discussion ---------- [Scheduler] Make `MessageGenerator` yield some scheduling context | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #50085, "replaces" #50096?, could help with #49864 | License | MIT | Doc PR | no doc yet for Scheduler This PR introduces a new `MessageContext` that `MessageGenerator` should use as key when yielding messages to provide more context about the scheduled message. The consumer of the scheduled messages can decide to use it or not. The PR also adds the wiring to add this context to the `ScheduledStamp` when using Scheduler within Messenger. This allows to add more context but without introducing a hard dependency on Messenger. /cc `@kbond` Note: this PR is not adding the scheduler name (cf #49864) because I don't know exactly where to wire it yet but I don't see anything preventing it to be added to the context once we know where it should belong. Commits ------- 3664d08 [Scheduler] Allow MessageGenerator to provide a MessageContext
I think we should create a hard dependency on
symfony/messenger
. This makes adding messenger-related features much easier. When using standalone, I've made the fact that messenger is used under the hood completely transparent.Scheduler
to use messenger'sWorker
under the hoodScheduleStamp
(schedule name, trigger, current run time, next run time). This could be moved to a followup PR but wanted to demonstrate how much easier it is to add this context with the hard dep./cc @upyx, any objections here?