• 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

0.0
/src/DnsClusterSettingsBuilder.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\Internal\Consts;
19

20
class DnsClusterSettingsBuilder
21
{
22
    private string $clusterDns = '';
23

24
    private int $maxDiscoverAttempts = Consts::DefaultMaxClusterDiscoverAttempts;
25

26
    private int $managerExternalHttpPort = Consts::DefaultClusterManagerExternalHttpPort;
27

28
    private float $gossipTimeout = 1.0;
29

30
    private bool $preferRandomNode = false;
31

32
    public function setClusterDns(string $clusterDns): self
33
    {
34
        if (empty($clusterDns)) {
×
35
            throw new InvalidArgumentException('Cluster DNS cannot be empty');
×
36
        }
37

38
        $this->clusterDns = $clusterDns;
×
39

40
        return $this;
×
41
    }
42

43
    public function setMaxDiscoverAttempts(int $maxDiscoverAttempts): self
44
    {
45
        if ($maxDiscoverAttempts < 1) {
×
46
            throw new OutOfRangeException(\sprintf(
×
47
                'Max discover attempts value is out of range: %d. Allowed range: [1, PHP_INT_MAX]',
×
48
                $maxDiscoverAttempts
×
49
            ));
×
50
        }
51

52
        $this->maxDiscoverAttempts = $maxDiscoverAttempts;
×
53

54
        return $this;
×
55
    }
56

57
    public function setGossipTimeout(float $timeout): self
58
    {
59
        $this->gossipTimeout = $timeout;
×
60

61
        return $this;
×
62
    }
63

64
    public function preferRandomNode(): self
65
    {
66
        $this->preferRandomNode = true;
×
67

68
        return $this;
×
69
    }
70

71
    public function setClusterGossipPort(int $clusterGossipPort): self
72
    {
73
        if ($clusterGossipPort < 1) {
×
74
            throw new OutOfRangeException('Cluster Gossip Port must be positive');
×
75
        }
76

77
        $this->managerExternalHttpPort = $clusterGossipPort;
×
78

79
        return $this;
×
80
    }
81

82
    public function build(): ClusterSettings
83
    {
84
        return ClusterSettings::fromClusterDns(
×
85
            $this->clusterDns,
×
86
            $this->maxDiscoverAttempts,
×
87
            $this->managerExternalHttpPort,
×
88
            $this->gossipTimeout,
×
89
            $this->preferRandomNode
×
90
        );
×
91
    }
92
}
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

© 2026 Coveralls, Inc