Allow set poolName in Annotation (#5960)

This commit is contained in:
Deeka Wong 2023-07-19 16:52:12 +08:00 committed by GitHub
parent dfecb0fe72
commit b3119a2349
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -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
) {
}
}

View File

@ -19,7 +19,8 @@ class Producer extends AbstractAnnotation
{
public function __construct(
public string $exchange = '',
public string $routingKey = ''
public string $routingKey = '',
public ?string $pool = null
) {
}
}

View File

@ -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();

View File

@ -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;

View File

@ -15,6 +15,8 @@ use Hyperf\Amqp\Builder\ExchangeBuilder;
interface MessageInterface
{
public function setPoolName(string $name);
/**
* Pool name for amqp.
*/

View File

@ -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);
}
}
}