10up / WP-Minions

ARCHIVED: Job Queue for WordPress
GNU General Public License v2.0
230 stars 40 forks source link

Include GearmanJob instance as argument for job action? #17

Closed nerrad closed 8 years ago

nerrad commented 8 years ago

Is there opposition to including the instance of GearmanJob as an argument on these actions? The primary purpose is so that the instance is exposed for any client code hooking in to do things. An example is I want to log the $job->unique() along with other attributes of what's happening when its being executed.

If no opposition I can whip up a pull request. Something like:

do_action( 'wp_async_task_before_job', $hook, $job );
do_action( 'wp_async_task_before_job_' . $hook, $job );

do_action( $hook, $args, $job );

do_action( 'wp_async_task_after_job', $hook, $job );
do_action( 'wp_async_task_after_job_' . $hook, $job );
dsawardekar commented 8 years ago

@nerrad Sounds good to me, @cmmarslender thoughts?

Note, The public api is fairly limited though. Just register and work. If you need to extend the implementation, you might want to checkout the constants, WP_GEARS_CLIENT_CLASS and WP_GEARS_WORKER_CLASS. These allow you to swap out the default Gearman implementation with a custom one.

nerrad commented 8 years ago

Yah I'm aware I can use the constant and will do that if adding GearmanJob instance to the actions is not desired. It's preferable to use the action though so any further changes made to the bundled class are easier to manage (especially when its for a minor thing like adding logging or something like that).