Skip to content

Commit

Permalink
fix: add readTimeout on factory and use it only as float
Browse files Browse the repository at this point in the history
  • Loading branch information
misaert committed Nov 6, 2023
1 parent 3031b6d commit bc1eae3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TRANSPORT_DSN="redis://127.0.0.1:6379" ./bin/freddie

Optional parameters you can pass in the DSN's query string:
- `pingInterval` - regularly ping Redis connection, which will help detect outages (default `2.0`)
- `readTimeout` - max duration in seconds of a ping or publish request (default `null`)
- `readTimeout` - max duration in seconds of a ping or publish request (default `0.0`: considered disabled)

_Alternatively, you can set this variable into `.env.local`._

Expand Down
2 changes: 1 addition & 1 deletion src/Hub/Transport/Redis/RedisTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
'channel' => 'mercure',
'key' => 'mercureUpdates',
'pingInterval' => 2.0,
'readTimeout' => null,
'readTimeout' => 0.0,
]);
$this->options = $resolver->resolve($options);
if ($this->options['pingInterval']) {
Expand Down
1 change: 1 addition & 0 deletions src/Hub/Transport/Redis/RedisTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function create(string $dsn): TransportInterface
'size' => (int) max(0, $parsed->getParameter('size', 0)),
'trimInterval' => (float) max(0, $parsed->getParameter('trimInterval', 0.0)),
'pingInterval' => (float) max(0, $parsed->getParameter('pingInterval', 2.0)),
'readTimeout' => (float) max(0, $parsed->getParameter('readTimeout', 0.0)),
'channel' => (string) $parsed->getParameter('channel', 'mercure'),
'key' => (string) $parsed->getParameter('key', 'mercureUpdates'),
],
Expand Down
4 changes: 2 additions & 2 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function extract_last_event_id(ServerRequestInterface $request): ?string
* @param PromiseInterface<T> $promise
* @return PromiseInterface<T>
*/
function maybeTimeout(PromiseInterface $promise, ?float $time = null): PromiseInterface
function maybeTimeout(PromiseInterface $promise, float $time = 0.0): PromiseInterface
{
return null === $time ? $promise : timeout($promise, $time);
return 0.0 === $time ? $promise : timeout($promise, $time);
}

0 comments on commit bc1eae3

Please sign in to comment.