Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 9, 2020
1 parent ed6bd2e commit 095d922
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Bus/Queueable.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ trait Queueable
public $delay;

/**
* Indicate the job should be dispatched after database transactions.
* Indicates whether the job should be dispatched after all database transactions have committed.
*
* @var bool|null
*/
Expand Down Expand Up @@ -141,7 +141,7 @@ public function delay($delay)
}

/**
* Indicate that the job should be dispatched after database transactions.
* Indicate that the job should be dispatched after all database transactions have committed.
*
* @return $this
*/
Expand All @@ -153,7 +153,7 @@ public function afterCommit()
}

/**
* Indicate that the job should be dispatched before database transactions.
* Indicate that the job should not wait until database transactions have been committed before dispatching.
*
* @return $this
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Illuminate/Events/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,15 @@ protected function propagateListenerOptions($listener, $job)
{
return tap($job, function ($job) use ($listener) {
$job->tries = $listener->tries ?? null;

$job->backoff = method_exists($listener, 'backoff')
? $listener->backoff() : ($listener->backoff ?? null);

$job->timeout = $listener->timeout ?? null;

$job->dispatchAfterCommit = property_exists($listener, 'dispatchAfterCommit')
? $listener->dispatchAfterCommit : null;

$job->retryUntil = method_exists($listener, 'retryUntil')
? $listener->retryUntil() : null;
});
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Bus/PendingDispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function delay($delay)
}

/**
* Indicate that the job should be dispatched after database transactions.
* Indicate that the job should be dispatched after all database transactions have committed.
*
* @return $this
*/
Expand All @@ -112,7 +112,7 @@ public function afterCommit()
}

/**
* Indicate that the job should be dispatched before database transactions.
* Indicate that the job should not wait until database transactions have been committed before dispatching.
*
* @return $this
*/
Expand Down
35 changes: 11 additions & 24 deletions src/Illuminate/Queue/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Closure;
use DateTimeInterface;
use Illuminate\Container\Container;
use Illuminate\Database\DatabaseTransactionManager;
use Illuminate\Support\Arr;
use Illuminate\Support\InteractsWithTime;
use Illuminate\Support\Str;
Expand All @@ -28,18 +29,18 @@ abstract class Queue
protected $connectionName;

/**
* The create payload callbacks.
* Indicates that jobs should be dispatched after all database transactions have committed.
*
* @var callable[]
* @return $this
*/
protected static $createPayloadCallbacks = [];
protected $dispatchAfterCommit;

/**
* Indicate the job should be dispatched after database transactions.
* The create payload callbacks.
*
* @var bool|null
* @var callable[]
*/
protected $dispatchAfterCommit;
protected static $createPayloadCallbacks = [];

/**
* Push a new job onto the queue.
Expand Down Expand Up @@ -278,15 +279,17 @@ protected function enqueueUsing($job, $payload, $queue, $delay, $callback)
if ($this->shouldDispatchAfterCommit($job) &&
$this->container->bound('db.transactions')) {
return $this->container->make('db.transactions')->addCallback(
$this->afterCommitCallback($payload, $queue, $delay, $callback)
function () use ($payload, $queue, $delay, $callback) {
return $callback($payload, $queue, $delay);
}
);
}

return $callback($payload, $queue, $delay);
}

/**
* Determine if the job should be dispatched after database transactions.
* Determine if the job should be dispatched after all database transactions have committed.
*
* @param \Closure|string|object $job
* @return bool
Expand All @@ -304,22 +307,6 @@ protected function shouldDispatchAfterCommit($job)
return false;
}

/**
* Create the after commit callback.
*
* @param string $payload
* @param string $queue
* @param \DateTimeInterface|\DateInterval|int|null $delay
* @param callable $callback
* @return callable
*/
protected function afterCommitCallback($payload, $queue, $delay, $callback)
{
return function () use ($delay, $queue, $payload, $callback) {
return $callback($payload, $queue, $delay);
};
}

/**
* Get the connection name for the queue.
*
Expand Down

0 comments on commit 095d922

Please sign in to comment.