mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Allow set poolName in Annotation (#5960)
This commit is contained in:
parent
dfecb0fe72
commit
b3119a2349
@ -46,6 +46,7 @@
|
||||
- [#5920](https://github.com/hyperf/hyperf/pull/5920) add the `\Stringable` interface to classes that have `__toString()` method.
|
||||
- [#5945](https://github.com/hyperf/hyperf/pull/5945) Don't sync config frequently when listen more than one namespace for apollo config center.
|
||||
- [#5948](https://github.com/hyperf/hyperf/pull/5948) Optimized `Hyperf\Coroutine\Locker`.
|
||||
- [#5960](https://github.com/hyperf/hyperf/pull/5960) Allowed set poolName in Annotation.
|
||||
|
||||
## Removed
|
||||
|
||||
|
@ -24,7 +24,8 @@ class Consumer extends AbstractAnnotation
|
||||
public string $name = 'Consumer',
|
||||
public ?int $nums = null,
|
||||
public ?bool $enable = null,
|
||||
public int $maxConsumption = 0
|
||||
public int $maxConsumption = 0,
|
||||
public ?string $pool = null
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ class Producer extends AbstractAnnotation
|
||||
{
|
||||
public function __construct(
|
||||
public string $exchange = '',
|
||||
public string $routingKey = ''
|
||||
public string $routingKey = '',
|
||||
public ?string $pool = null
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ class ConsumerManager
|
||||
$instance->setContainer($this->container);
|
||||
$annotation->maxConsumption && $instance->setMaxConsumption($annotation->maxConsumption);
|
||||
! is_null($annotation->nums) && $instance->setNums($annotation->nums);
|
||||
$annotation->pool && $instance->setPoolName($annotation->pool);
|
||||
$process = $this->createProcess($instance);
|
||||
$process->nums = $instance->getNums();
|
||||
$process->name = $annotation->name . '-' . $instance->getQueue();
|
||||
|
@ -57,6 +57,12 @@ abstract class Message implements MessageInterface
|
||||
return $this->routingKey;
|
||||
}
|
||||
|
||||
public function setPoolName(string $name): static
|
||||
{
|
||||
$this->poolName = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPoolName(): string
|
||||
{
|
||||
return $this->poolName;
|
||||
|
@ -15,6 +15,8 @@ use Hyperf\Amqp\Builder\ExchangeBuilder;
|
||||
|
||||
interface MessageInterface
|
||||
{
|
||||
public function setPoolName(string $name);
|
||||
|
||||
/**
|
||||
* Pool name for amqp.
|
||||
*/
|
||||
|
@ -69,6 +69,7 @@ class Producer extends Builder
|
||||
if ($annotation) {
|
||||
$annotation->routingKey && $producerMessage->setRoutingKey($annotation->routingKey);
|
||||
$annotation->exchange && $producerMessage->setExchange($annotation->exchange);
|
||||
$annotation->pool && $producerMessage->setPoolName($annotation->pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user