Skip to content

Commit 1657d63

Browse files
committed
Refactor to consistently use RetryExecutor for all transports
1 parent ae37876 commit 1657d63

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/Resolver/Factory.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private function createExecutor($nameserver, LoopInterface $loop)
128128
);
129129
}
130130

131-
return new CoopExecutor($executor);
131+
return new CoopExecutor(new RetryExecutor($executor));
132132
}
133133

134134
private function createTcpExecutor($nameserver, LoopInterface $loop)
@@ -142,15 +142,13 @@ private function createTcpExecutor($nameserver, LoopInterface $loop)
142142

143143
private function createUdpExecutor($nameserver, LoopInterface $loop)
144144
{
145-
return new RetryExecutor(
146-
new TimeoutExecutor(
147-
new UdpTransportExecutor(
148-
$nameserver,
149-
$loop
150-
),
151-
5.0,
145+
return new TimeoutExecutor(
146+
new UdpTransportExecutor(
147+
$nameserver,
152148
$loop
153-
)
149+
),
150+
5.0,
151+
$loop
154152
);
155153
}
156154
}

tests/Resolver/FactoryTest.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ public function createWithoutSchemeShouldCreateResolverWithSelectiveUdpAndTcpExe
3636

3737
$ref = new \ReflectionProperty($coopExecutor, 'executor');
3838
$ref->setAccessible(true);
39-
$selectiveExecutor = $ref->getValue($coopExecutor);
39+
$retryExecutor = $ref->getValue($coopExecutor);
40+
41+
$this->assertInstanceOf('React\Dns\Query\RetryExecutor', $retryExecutor);
42+
43+
$ref = new \ReflectionProperty($retryExecutor, 'executor');
44+
$ref->setAccessible(true);
45+
$selectiveExecutor = $ref->getValue($retryExecutor);
4046

4147
$this->assertInstanceOf('React\Dns\Query\SelectiveTransportExecutor', $selectiveExecutor);
4248

4349
// udp below:
4450

4551
$ref = new \ReflectionProperty($selectiveExecutor, 'datagramExecutor');
4652
$ref->setAccessible(true);
47-
$retryExecutor = $ref->getValue($selectiveExecutor);
48-
49-
$this->assertInstanceOf('React\Dns\Query\RetryExecutor', $retryExecutor);
50-
51-
$ref = new \ReflectionProperty($retryExecutor, 'executor');
52-
$ref->setAccessible(true);
53-
$timeoutExecutor = $ref->getValue($retryExecutor);
53+
$timeoutExecutor = $ref->getValue($selectiveExecutor);
5454

5555
$this->assertInstanceOf('React\Dns\Query\TimeoutExecutor', $timeoutExecutor);
5656

@@ -124,7 +124,13 @@ public function createWithTcpSchemeShouldCreateResolverWithTcpExecutorStack()
124124

125125
$ref = new \ReflectionProperty($coopExecutor, 'executor');
126126
$ref->setAccessible(true);
127-
$timeoutExecutor = $ref->getValue($coopExecutor);
127+
$retryExecutor = $ref->getValue($coopExecutor);
128+
129+
$this->assertInstanceOf('React\Dns\Query\RetryExecutor', $retryExecutor);
130+
131+
$ref = new \ReflectionProperty($retryExecutor, 'executor');
132+
$ref->setAccessible(true);
133+
$timeoutExecutor = $ref->getValue($retryExecutor);
128134

129135
$this->assertInstanceOf('React\Dns\Query\TimeoutExecutor', $timeoutExecutor);
130136

@@ -154,7 +160,13 @@ public function createWithConfigWithTcpNameserverSchemeShouldCreateResolverWithT
154160

155161
$ref = new \ReflectionProperty($coopExecutor, 'executor');
156162
$ref->setAccessible(true);
157-
$timeoutExecutor = $ref->getValue($coopExecutor);
163+
$retryExecutor = $ref->getValue($coopExecutor);
164+
165+
$this->assertInstanceOf('React\Dns\Query\RetryExecutor', $retryExecutor);
166+
167+
$ref = new \ReflectionProperty($retryExecutor, 'executor');
168+
$ref->setAccessible(true);
169+
$timeoutExecutor = $ref->getValue($retryExecutor);
158170

159171
$this->assertInstanceOf('React\Dns\Query\TimeoutExecutor', $timeoutExecutor);
160172

0 commit comments

Comments
 (0)