Skip to content
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

[5.4] Queue worker will pass connection + queue name to Looping event #18975

Closed
wants to merge 1 commit into from
Closed

[5.4] Queue worker will pass connection + queue name to Looping event #18975

wants to merge 1 commit into from

Conversation

stierler
Copy link
Contributor

This allows the Queue\Events\Looping to pass along the connection and queue names. I was working on some more detailed logging/status monitoring of different job processors for queues across multiple servers, and realized there was no easy way to hook onto this (I didn't want to hook onto the JobProcessing hook as this was too noisy)

I wrote a basic test as well, but it was somewhat hacky so I didn't include (there are also currently no other tests that look for the Looping event anywhere currently). I can include in comments if you think it would be useful.

Basic example of what I was trying to accomplish below. Please let me know if you think this is unnecessary/overkill and/or a better approach

    // Log an event at the beginning of each job processor loop.
    \Queue::looping(function(\Illuminate\Queue\Events\Looping $event) {
        \Log::info('Queue '.$event->queue.' running on connection '.$event->connectionName);
    });

@laurencei
Copy link
Contributor

laurencei commented Apr 28, 2017

Perhaps a different option is to modify the WorkerOptions, and add the queue and connection name there as part of the data object passed around.

That way none of the function signatures need to change, but you get the same functionality. Then you just pass the WorkerOptions into the Looping event, which gives you all the options used for the loop - which might help...

@stierler
Copy link
Contributor Author

stierler commented Apr 30, 2017

If anything, I guess the avoid the signatures changing without any harm to anyone would be to allow the two variables on the constructor to be null.

public function __construct($connectionName, $queue)
this way if on the rare change someone is actually using this event already, it won't have any breaking change

Edit: I decided not to, as this isn't consistent with any of the other Queue Events, unless @taylorotwell thinks otherwise. If anything, this PR would make at least one more event more consistent with the rest - the last that is empty is "WorkerStopping"

@taylorotwell
Copy link
Member

Please send this to master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants