| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- declare(strict_types=1);
- /**
- * This file is part of Hyperf.
- *
- * @link https://www.hyperf.io
- * @document https://hyperf.wiki
- * @contact group@hyperf.io
- * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
- */
- namespace Hyperf\Pool;
- use Hyperf\Contract\PoolOptionInterface;
- class PoolOption implements PoolOptionInterface
- {
- /**
- * Min connections of pool.
- * This means the pool will create $minConnections connections when
- * pool initialization.
- */
- private int $minConnections;
- /**
- * Max connections of pool.
- */
- private int $maxConnections;
- /**
- * The timeout of connect the connection.
- * Default value is 10 seconds.
- */
- private float $connectTimeout;
- /**
- * The timeout of pop a connection.
- * Default value is 3 seconds.
- */
- private float $waitTimeout;
- /**
- * Heartbeat of connection.
- * If the value is 10, then means 10 seconds.
- * If the value is -1, then means does not need the heartbeat.
- * Default value is -1.
- */
- private float $heartbeat;
- /**
- * The max idle time for connection.
- */
- private float $maxIdleTime;
- /**
- * The events which will be triggered by releasing connection and so on.
- * @var array<int, string>
- */
- private array $events;
- public function __construct(
- int $minConnections = 1,
- int $maxConnections = 10,
- float $connectTimeout = 10.0,
- float $waitTimeout = 3.0,
- float $heartbeat = -1,
- float $maxIdleTime = 60.0,
- array $events = [],
- ) {
- $this->minConnections = $minConnections;
- $this->maxConnections = $maxConnections;
- $this->connectTimeout = $connectTimeout;
- $this->waitTimeout = $waitTimeout;
- $this->heartbeat = $heartbeat;
- $this->maxIdleTime = $maxIdleTime;
- $this->events = $events;
- }
- public function getMaxConnections(): int
- {
- return $this->maxConnections;
- }
- public function setMaxConnections(int $maxConnections): static
- {
- $this->maxConnections = $maxConnections;
- return $this;
- }
- public function getMinConnections(): int
- {
- return $this->minConnections;
- }
- public function setMinConnections(int $minConnections): static
- {
- $this->minConnections = $minConnections;
- return $this;
- }
- public function getConnectTimeout(): float
- {
- return $this->connectTimeout;
- }
- public function setConnectTimeout(float $connectTimeout): static
- {
- $this->connectTimeout = $connectTimeout;
- return $this;
- }
- public function getHeartbeat(): float
- {
- return $this->heartbeat;
- }
- public function setHeartbeat(float $heartbeat): static
- {
- $this->heartbeat = $heartbeat;
- return $this;
- }
- public function getWaitTimeout(): float
- {
- return $this->waitTimeout;
- }
- public function setWaitTimeout(float $waitTimeout): static
- {
- $this->waitTimeout = $waitTimeout;
- return $this;
- }
- public function getMaxIdleTime(): float
- {
- return $this->maxIdleTime;
- }
- public function setMaxIdleTime(float $maxIdleTime): static
- {
- $this->maxIdleTime = $maxIdleTime;
- return $this;
- }
- public function getEvents(): array
- {
- return $this->events;
- }
- public function setEvents(array $events): static
- {
- $this->events = $events;
- return $this;
- }
- }
|