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

[6.x] Broadcaster - Improve ShouldBroadcastNow performance #30797

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Illuminate/Broadcasting/BroadcastManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Broadcasting\Broadcasters\RedisBroadcaster;
use Illuminate\Contracts\Broadcasting\Factory as FactoryContract;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcherContract;
use InvalidArgumentException;
use Psr\Log\LoggerInterface;
use Pusher\Pusher;
Expand Down Expand Up @@ -108,10 +109,8 @@ public function event($event = null)
*/
public function queue($event)
{
$connection = $event instanceof ShouldBroadcastNow ? 'sync' : null;

if (is_null($connection) && isset($event->connection)) {
$connection = $event->connection;
if ($event instanceof ShouldBroadcastNow) {
return $this->app->make(BusDispatcherContract::class)->dispatchNow(new BroadcastEvent(clone $event));
}

$queue = null;
Expand All @@ -124,7 +123,7 @@ public function queue($event)
$queue = $event->queue;
}

$this->app->make('queue')->connection($connection)->pushOn(
$this->app->make('queue')->connection($event->connection ?? null)->pushOn(
driesvints marked this conversation as resolved.
Show resolved Hide resolved
$queue, new BroadcastEvent(clone $event)
);
}
Expand Down