Repository navigation
Expand file tree
/
Copy pathPoolOption.php
More file actions
156 lines (131 loc) · 3.48 KB
/
Copy pathPoolOption.php
File metadata and controls
156 lines (131 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @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;
}
}