Commit 55dbfc7e authored by Dillenn Terumalai's avatar Dillenn Terumalai
Browse files

// WIP

parent 55ada549
......@@ -11,14 +11,17 @@ trait EventMap
*/
protected $events = [
Events\JobCancelled::class => [
Listeners\ExecuteJobCancelCallback::class,
Listeners\MarkJobAsCancelled::class
],
Events\JobFailed::class => [
Listeners\ExecuteJobFailureCallback::class,
Listeners\MarkJobAsFailed::class
],
Events\JobCompleted::class => [
Listeners\ExecuteJobSuccessCallback::class,
Listeners\MarkJobAsCompleted::class
],
......
<?php
namespace Dterumal\LaravelCluster\Listeners;
use Dterumal\LaravelCluster\Contracts\JobRepository;
use Dterumal\LaravelCluster\Events\JobCancelled;
class ExecuteJobCancelCallback
{
/**
* Handle the event.
*
* @param \Dterumal\LaravelCluster\Events\JobCancelled $event
* @return void
*/
public function handle(JobCancelled $event): void
{
$jobClass = $event->job->job;
if (method_exists($jobClass, 'onCancel')) {
$jobClass->onCancel($event->job);
}
}
}
<?php
namespace Dterumal\LaravelCluster\Listeners;
use Dterumal\LaravelCluster\Contracts\JobRepository;
use Dterumal\LaravelCluster\Events\JobCancelled;
class ExecuteJobFailureCallback
{
/**
* Handle the event.
*
* @param \Dterumal\LaravelCluster\Events\JobCancelled $event
* @return void
*/
public function handle(JobCancelled $event): void
{
$jobClass = $event->job->job;
if (method_exists($jobClass, 'onFailure')) {
$jobClass->onFailure($event->job);
}
}
}
<?php
namespace Dterumal\LaravelCluster\Listeners;
use Dterumal\LaravelCluster\Contracts\JobRepository;
use Dterumal\LaravelCluster\Events\JobCancelled;
class ExecuteJobSuccessCallback
{
/**
* Handle the event.
*
* @param \Dterumal\LaravelCluster\Events\JobCancelled $event
* @return void
*/
public function handle(JobCancelled $event): void
{
$jobClass = $event->job->job;
if (method_exists($jobClass, 'onSuccess')) {
$jobClass->onSuccess($event->job);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment