55
66use Innmind \TimeContinuum \{
77 Clock ,
8- Earth ,
9- ElapsedPeriod ,
8+ Period ,
109};
1110use Innmind \Filesystem \CaseSensitivity ;
1211use Innmind \Server \Status \EnvironmentPath ;
1312use Innmind \TimeWarp \Halt ;
1413use Innmind \IO \IO ;
15- use Innmind \Stream \{
16- Capabilities ,
17- Streams ,
18- };
1914use Innmind \Immutable \Maybe ;
2015
2116final class Config
2217{
2318 private Clock $ clock ;
2419 private CaseSensitivity $ caseSensitivity ;
25- private Capabilities $ streamCapabilities ;
2620 private IO $ io ;
2721 private Halt $ halt ;
2822 private EnvironmentPath $ path ;
2923 /** @var Maybe<positive-int> */
3024 private Maybe $ maxHttpConcurrency ;
31- /** @var Maybe<array{ElapsedPeriod , callable(): void}> */
25+ /** @var Maybe<array{Period , callable(): void}> */
3226 private Maybe $ httpHeartbeat ;
3327 private bool $ disableSSLVerification ;
3428
3529 /**
3630 * @param Maybe<positive-int> $maxHttpConcurrency
37- * @param Maybe<array{ElapsedPeriod , callable(): void}> $httpHeartbeat
31+ * @param Maybe<array{Period , callable(): void}> $httpHeartbeat
3832 */
3933 private function __construct (
4034 Clock $ clock ,
4135 CaseSensitivity $ caseSensitivity ,
42- Capabilities $ streamCapabilities ,
4336 IO $ io ,
4437 Halt $ halt ,
4538 EnvironmentPath $ path ,
@@ -49,7 +42,6 @@ private function __construct(
4942 ) {
5043 $ this ->clock = $ clock ;
5144 $ this ->caseSensitivity = $ caseSensitivity ;
52- $ this ->streamCapabilities = $ streamCapabilities ;
5345 $ this ->io = $ io ;
5446 $ this ->halt = $ halt ;
5547 $ this ->path = $ path ;
@@ -62,18 +54,14 @@ public static function of(): self
6254 {
6355 /** @var Maybe<positive-int> */
6456 $ maxHttpConcurrency = Maybe::nothing ();
65- /** @var Maybe<array{ElapsedPeriod , callable(): void}> */
57+ /** @var Maybe<array{Period , callable(): void}> */
6658 $ httpHeartbeat = Maybe::nothing ();
6759
6860 return new self (
69- new Earth \ Clock ,
61+ Clock:: live () ,
7062 CaseSensitivity::sensitive,
71- $ streams = Streams::fromAmbientAuthority (),
72- IO ::of (static fn (?ElapsedPeriod $ timeout ) => match ($ timeout ) {
73- null => $ streams ->watch ()->waitForever (),
74- default => $ streams ->watch ()->timeoutAfter ($ timeout ),
75- }),
76- new Halt \Usleep ,
63+ IO ::fromAmbientAuthority (),
64+ Halt \Usleep::new (),
7765 EnvironmentPath::of (match ($ path = \getenv ('PATH ' )) {
7866 false => '' ,
7967 default => $ path ,
@@ -92,7 +80,6 @@ public function withClock(Clock $clock): self
9280 return new self (
9381 $ clock ,
9482 $ this ->caseSensitivity ,
95- $ this ->streamCapabilities ,
9683 $ this ->io ,
9784 $ this ->halt ,
9885 $ this ->path ,
@@ -110,7 +97,6 @@ public function caseInsensitiveFilesystem(): self
11097 return new self (
11198 $ this ->clock ,
11299 CaseSensitivity::insensitive,
113- $ this ->streamCapabilities ,
114100 $ this ->io ,
115101 $ this ->halt ,
116102 $ this ->path ,
@@ -120,28 +106,6 @@ public function caseInsensitiveFilesystem(): self
120106 );
121107 }
122108
123- /**
124- * @psalm-mutation-free
125- */
126- public function useStreamCapabilities (Capabilities $ capabilities ): self
127- {
128- /** @psalm-suppress ImpureMethodCall This should be solved in the next innmind/io release */
129- return new self (
130- $ this ->clock ,
131- $ this ->caseSensitivity ,
132- $ capabilities ,
133- IO ::of (static fn (?ElapsedPeriod $ timeout ) => match ($ timeout ) {
134- null => $ capabilities ->watch ()->waitForever (),
135- default => $ capabilities ->watch ()->timeoutAfter ($ timeout ),
136- }),
137- $ this ->halt ,
138- $ this ->path ,
139- $ this ->maxHttpConcurrency ,
140- $ this ->httpHeartbeat ,
141- $ this ->disableSSLVerification ,
142- );
143- }
144-
145109 /**
146110 * @psalm-mutation-free
147111 */
@@ -150,7 +114,6 @@ public function haltProcessVia(Halt $halt): self
150114 return new self (
151115 $ this ->clock ,
152116 $ this ->caseSensitivity ,
153- $ this ->streamCapabilities ,
154117 $ this ->io ,
155118 $ halt ,
156119 $ this ->path ,
@@ -168,7 +131,6 @@ public function withEnvironmentPath(EnvironmentPath $path): self
168131 return new self (
169132 $ this ->clock ,
170133 $ this ->caseSensitivity ,
171- $ this ->streamCapabilities ,
172134 $ this ->io ,
173135 $ this ->halt ,
174136 $ path ,
@@ -188,7 +150,6 @@ public function limitHttpConcurrencyTo(int $max): self
188150 return new self (
189151 $ this ->clock ,
190152 $ this ->caseSensitivity ,
191- $ this ->streamCapabilities ,
192153 $ this ->io ,
193154 $ this ->halt ,
194155 $ this ->path ,
@@ -203,12 +164,11 @@ public function limitHttpConcurrencyTo(int $max): self
203164 *
204165 * @param callable(): void $heartbeat
205166 */
206- public function withHttpHeartbeat (ElapsedPeriod $ timeout , callable $ heartbeat ): self
167+ public function withHttpHeartbeat (Period $ timeout , callable $ heartbeat ): self
207168 {
208169 return new self (
209170 $ this ->clock ,
210171 $ this ->caseSensitivity ,
211- $ this ->streamCapabilities ,
212172 $ this ->io ,
213173 $ this ->halt ,
214174 $ this ->path ,
@@ -226,7 +186,6 @@ public function disableSSLVerification(): self
226186 return new self (
227187 $ this ->clock ,
228188 $ this ->caseSensitivity ,
229- $ this ->streamCapabilities ,
230189 $ this ->io ,
231190 $ this ->halt ,
232191 $ this ->path ,
@@ -252,14 +211,6 @@ public function filesystemCaseSensitivity(): CaseSensitivity
252211 return $ this ->caseSensitivity ;
253212 }
254213
255- /**
256- * @internal
257- */
258- public function streamCapabilities (): Capabilities
259- {
260- return $ this ->streamCapabilities ;
261- }
262-
263214 /**
264215 * @internal
265216 */
@@ -297,7 +248,7 @@ public function maxHttpConcurrency(): Maybe
297248 /**
298249 * @internal
299250 *
300- * @return Maybe<array{ElapsedPeriod , callable(): void}>
251+ * @return Maybe<array{Period , callable(): void}>
301252 */
302253 public function httpHeartbeat (): Maybe
303254 {
0 commit comments