-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[11.x] Introduce OnQueue
and OnConnection
attributes for jobs
#54229
base: 11.x
Are you sure you want to change the base?
Conversation
OnQueue
and OnConnection
attributesOnQueue
and OnConnection
attributes for jobs
An |
But then how would I make my super funny joke about |
I see, touché 😂👍🏻 |
Yet another way to slow down the framework. |
If you want super fast, maybe, you shouldn't use Laravel in the first place 🙄 |
The problem
PHP is weird about traits. If a class uses a trait, then it cannot re-declare properties from the trait with differing values. (Though if another class uses the trait and then you extend that class, you can 🙃)
This is problematic with setting queue/connections, where it would be great if we could just define the
$queue
and$connection
properties.An example with Queueable
Setting queue/connection is annoying
My jobs do not need to be dynamic in where they are dispatched. If it's a SyncAthletesJob, it's always on the import queue (and the import queue is always on the redis_medium connection, but that's not a problem solved here).
The two not-so-pretty ways of specifying this
The solution
Introduce
OnQueue
andOnConnection
attributes.Now the above job can look clean 🧹 and I never have to worry about specifying queue/connection in calling code or inside of the constructor.
Bonus: when I call
dispatch(new SyncAthletesJob($teamId))
I get the same benefit.Follow ups
Does this need added for queued event listeners as well? If so, we could share these attributes, but leaving them in Foundation/Bus doesn't really make sense.
Additional attributes for
#[OnDasher]
,#[OnDancer]
,#[OnPrancer]
,#[OnVixen]
, et cetera