Last active
December 4, 2022 06:18
-
-
Save browner12/2146d3fe045a738183b7231c6ef5686c to your computer and use it in GitHub Desktop.
Queue Prefixing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the queue prefix. | |
* | |
* @return string | |
*/ | |
public function getPrefix() | |
{ | |
return config('queue.prefix'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', ''), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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