Skip to content

Instantly share code, notes, and snippets.

@browner12
Last active December 4, 2022 06:18
Show Gist options
  • Save browner12/2146d3fe045a738183b7231c6ef5686c to your computer and use it in GitHub Desktop.
Save browner12/2146d3fe045a738183b7231c6ef5686c to your computer and use it in GitHub Desktop.
Queue Prefixing
/**
* Get the queue or return the default.
*
* @param string|null $queue
* @return string
*/
public function getQueue($queue)
{
$queue = $queue ?: $this->default;
return $this->getPrefix() . $queue;
}
/**
* Get the queue prefix.
*
* @return string
*/
public function getPrefix()
{
return config('queue.prefix');
}
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Queue Prefix
|--------------------------------------------------------------------------
|
| In order to prevent crosstalk between applications on the same server
| you may add a 'prefix' to your queues. You will still interact
| with your queues the same way, and the prefix will be applied
| automatically where appropraite.
|
*/
'prefix' => env('QUEUE_PREFIX', ''),
/**
* Get the queue name for the worker.
*
* @param string $connection
* @return string
*/
protected function getQueue($connection)
{
$queue = $this->option('queue') ?: $this->laravel['config']->get(
"queue.connections.{$connection}.queue", 'default'
);
return $this->laravel['config']->get("queue.prefix") . $queue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment