• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prooph / event-store-client / 9555551525

17 Jun 2024 10:16PM UTC coverage: 70.262% (-1.1%) from 71.395%
9555551525

push

github

prolic
update coveralls repo token

3466 of 4933 relevant lines covered (70.26%)

67.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.96
/src/ConnectionSettings.php
1
<?php
2

3
/**
4
 * This file is part of `prooph/event-store-client`.
5
 * (c) 2018-2024 Alexander Miertsch <kontakt@codeliner.ws>
6
 * (c) 2018-2024 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace Prooph\EventStoreClient;
15

16
use Prooph\EventStore\Exception\InvalidArgumentException;
17
use Prooph\EventStore\Exception\OutOfRangeException;
18
use Prooph\EventStore\UserCredentials;
19
use Psr\Log\LoggerInterface as Logger;
20

21
/**
22
 * All times are milliseconds
23
 */
24
final class ConnectionSettings
25
{
26
    public static function default(): self
27
    {
28
        return (new ConnectionSettingsBuilder())->build();
22✔
29
    }
30

31
    public static function create(): ConnectionSettingsBuilder
32
    {
33
        return new ConnectionSettingsBuilder();
5✔
34
    }
35

36
    /**
37
     * @internal
38
     *
39
     * @param list<GossipSeed> $gossipSeeds
40
     */
41
    public function __construct(
42
        private Logger $log,
43
        private bool $verboseLogging,
44
        private int $maxQueueSize,
45
        private int $maxConcurrentItems,
46
        private int $maxRetries,
47
        private int $maxReconnections,
48
        private bool $requireMaster,
49
        private float $reconnectionDelay,
50
        private float $operationTimeout,
51
        private float $operationTimeoutCheckPeriod,
52
        private ?UserCredentials $defaultUserCredentials,
53
        private bool $useSslConnection,
54
        private string $targetHost,
55
        private bool $validateServer,
56
        private bool $failOnNoServerResponse,
57
        private float $heartbeatInterval,
58
        private float $heartbeatTimeout,
59
        private string $clusterDns,
60
        private int $maxDiscoverAttempts,
61
        private int $externalGossipPort,
62
        private array $gossipSeeds,
63
        private float $gossipTimeout,
64
        private bool $preferRandomNode,
65
        private float $clientConnectionTimeout
66
    ) {
67
        if ($heartbeatInterval >= 5) {
433✔
68
            throw new InvalidArgumentException('Heartbeat interval must be less than 5 sec');
×
69
        }
70

71
        if ($maxQueueSize < 1) {
433✔
72
            throw new InvalidArgumentException('Max queue size must be positive');
×
73
        }
74

75
        if ($maxConcurrentItems < 1) {
433✔
76
            throw new InvalidArgumentException('Max concurrent items must be positive');
×
77
        }
78

79
        if ($maxRetries < -1) {
433✔
80
            throw new OutOfRangeException(\sprintf(
×
81
                'Max retries is out of range %d. Allowed range: [-1, PHP_INT_MAX].',
×
82
                $maxReconnections
×
83
            ));
×
84
        }
85

86
        if ($maxReconnections < -1) {
433✔
87
            throw new OutOfRangeException(\sprintf(
×
88
                'Max reconnections is out of range %d. Allowed range: [-1, PHP_INT_MAX].',
×
89
                $maxReconnections
×
90
            ));
×
91
        }
92

93
        if ($useSslConnection && empty($targetHost)) {
433✔
94
            throw new InvalidArgumentException('Target host must be not empty when using SSL');
×
95
        }
96
    }
97

98
    public function log(): Logger
99
    {
100
        return $this->log;
413✔
101
    }
102

103
    public function verboseLogging(): bool
104
    {
105
        return $this->verboseLogging;
410✔
106
    }
107

108
    public function maxQueueSize(): int
109
    {
110
        return $this->maxQueueSize;
395✔
111
    }
112

113
    public function maxConcurrentItems(): int
114
    {
115
        return $this->maxConcurrentItems;
394✔
116
    }
117

118
    public function maxRetries(): int
119
    {
120
        return $this->maxRetries;
399✔
121
    }
122

123
    public function maxReconnections(): int
124
    {
125
        return $this->maxReconnections;
×
126
    }
127

128
    public function requireMaster(): bool
129
    {
130
        return $this->requireMaster;
380✔
131
    }
132

133
    public function reconnectionDelay(): float
134
    {
135
        return $this->reconnectionDelay;
×
136
    }
137

138
    public function operationTimeout(): float
139
    {
140
        return $this->operationTimeout;
397✔
141
    }
142

143
    public function operationTimeoutCheckPeriod(): float
144
    {
145
        return $this->operationTimeoutCheckPeriod;
420✔
146
    }
147

148
    public function defaultUserCredentials(): ?UserCredentials
149
    {
150
        return $this->defaultUserCredentials;
409✔
151
    }
152

153
    public function useSslConnection(): bool
154
    {
155
        return $this->useSslConnection;
413✔
156
    }
157

158
    public function targetHost(): string
159
    {
160
        return $this->targetHost;
406✔
161
    }
162

163
    public function validateServer(): bool
164
    {
165
        return $this->validateServer;
405✔
166
    }
167

168
    public function failOnNoServerResponse(): bool
169
    {
170
        return $this->failOnNoServerResponse;
×
171
    }
172

173
    public function heartbeatInterval(): float
174
    {
175
        return $this->heartbeatInterval;
16✔
176
    }
177

178
    public function heartbeatTimeout(): float
179
    {
180
        return $this->heartbeatTimeout;
3✔
181
    }
182

183
    public function clusterDns(): string
184
    {
185
        return $this->clusterDns;
2✔
186
    }
187

188
    public function maxDiscoverAttempts(): int
189
    {
190
        return $this->maxDiscoverAttempts;
5✔
191
    }
192

193
    public function externalGossipPort(): int
194
    {
195
        return $this->externalGossipPort;
×
196
    }
197

198
    public function gossipSeeds(): array
199
    {
200
        return $this->gossipSeeds;
9✔
201
    }
202

203
    public function gossipTimeout(): float
204
    {
205
        return $this->gossipTimeout;
5✔
206
    }
207

208
    public function preferRandomNode(): bool
209
    {
210
        return $this->preferRandomNode;
5✔
211
    }
212

213
    public function clientConnectionTimeout(): float
214
    {
215
        return $this->clientConnectionTimeout;
405✔
216
    }
217

218
    public function withDefaultCredentials(UserCredentials $userCredentials): self
219
    {
220
        $clone = clone $this;
3✔
221
        $clone->defaultUserCredentials = $userCredentials;
3✔
222

223
        return $clone;
3✔
224
    }
225
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc