|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GroupByInc\API\Config; |
|
4
|
|
|
|
|
5
|
|
|
class ConnectionConfiguration |
|
6
|
|
|
{ |
|
7
|
|
|
|
|
8
|
|
|
const DEFAULT_TIMEOUT = 30; |
|
9
|
|
|
const DEFAULT_CONNECT_TIMEOUT = 15; |
|
10
|
|
|
const DEFAULT_MAX_CONNECTIONS = 200; |
|
11
|
|
|
|
|
12
|
|
|
private $timeout; |
|
13
|
|
|
private $connectTimeout; |
|
14
|
|
|
private $maxConnections; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* ConnectionConfiguration constructor. |
|
18
|
|
|
* @param int $timeout in seconds |
|
19
|
|
|
* @param int $connectTimeout in seconds |
|
20
|
|
|
* @param int $maxConnections maximum connections cURL will allow at one time. |
|
21
|
|
|
*/ |
|
22
|
|
|
public function __construct($timeout = self::DEFAULT_TIMEOUT, $connectTimeout = self::DEFAULT_CONNECT_TIMEOUT, $maxConnections = self::DEFAULT_MAX_CONNECTIONS) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->timeout = $timeout; |
|
25
|
|
|
$this->connectTimeout = $connectTimeout; |
|
26
|
|
|
$this->maxConnections = $maxConnections; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @return int |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getTimeout() |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->timeout; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param int $timeout seconds |
|
40
|
|
|
* @return ConnectionConfiguration |
|
41
|
|
|
*/ |
|
42
|
|
|
public function setTimeout($timeout) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->timeout = $timeout; |
|
45
|
|
|
return $this; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return int |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getConnectTimeout() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->connectTimeout; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param int $connectTimeout seconds |
|
58
|
|
|
* @return ConnectionConfiguration |
|
59
|
|
|
*/ |
|
60
|
|
|
public function setConnectTimeout($connectTimeout) |
|
61
|
|
|
{ |
|
62
|
|
|
$this->connectTimeout = $connectTimeout; |
|
63
|
|
|
return $this; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return int |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getMaxConnections() |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->maxConnections; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param int $maxConnections seconds |
|
76
|
|
|
* @return ConnectionConfiguration |
|
77
|
|
|
*/ |
|
78
|
|
|
public function setMaxConnections($maxConnections) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->maxConnections = $maxConnections; |
|
81
|
|
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
} |