A common problem I have is that it's hard to deal with tags on queued event listeners.
On a regular job, you have the payload available on the constructor, so you can use that as usual, e.g:
public function tags()
{
return ['user_id' => $this->userId];
}
On an event listener, the event instance is passed to the handle method, so when Horizon calls ->tags(), we can't access any context.
This PR aims to improve that by storing the event that's being handled when building tags, and passing that event instance to the tags method, so we can do something like this:
<?php
class MyEventListener implements ShouldQueue
{
public function handle(MyEvent $event)
{}
public function tags(MyEvent $event)
{
return [
'context_id' => $event->uniqueId(),
];
}
}
A common problem I have is that it's hard to deal with tags on queued event listeners. On a regular job, you have the payload available on the constructor, so you can use that as usual, e.g:
On an event listener, the event instance is passed to the
handle
method, so when Horizon calls->tags()
, we can't access any context. This PR aims to improve that by storing the event that's being handled when building tags, and passing that event instance to the tags method, so we can do something like this: