Replies: 1 comment 1 reply
-
But you can just write |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How can I compose a single Schedule from different places in code through some kind of extension points?
My use case is that:
bin/console messenger:consume scheduler_NAME
worker running. I want to keep the infrastructure simple without running many different workers.The "convenience" attributes
#[AsPeriodicTask]
and#[AsCronTask]
do what I am looking for - they add new triggers to the schedule. However, I couldn't find a way to be able to add new triggers through "rich" PHP code where more customization can be made. See code below.This defines the
foo
schedule with a single trigger:Now, in a different service, I would like to add another trigger to the existing schedule. I tried two approaches:
#[AsSchedule]
attribute.This does not work (as could be expected) and only one of the duplicate
foo
schedules will be registered - the other is completely ignored.FooSchedule
in a service. This one I thought should work, but I get container build errors.This results in:
Looking at the
FooSchedule
class, which is registered as a service, I see that it is overwritten in the container and assigned a different class!My
FooSchedule
is hidden behind a decorator (I think) and the DI fails.So, given that these do not work, what is the recommended and supported way of composing schedules? I have scoured the documentation and all the examples I have come across only show a simplistic case where the schedule is defined in one class.
I am thinking that I could collect all the "extending services" myself through custom tags and autowiring in the Schedule class, but it feels there should be a more out-of-the-box way to do that.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions