Allow configure heartbeat_interval

This commit is contained in:
2021-01-23 02:16:29 +03:00
parent e821f04ebe
commit 9f95dff2ec
2 changed files with 22 additions and 8 deletions

View File

@@ -22,16 +22,21 @@ use const PHP_EOL;
*/
abstract class Connection
{
public ?Socket $socket = null;
private string $address;
protected LoggerInterface $logger;
private ?Socket $socket = null;
private bool $closed = false;
private string $address;
private LoggerInterface $logger;
/**
* @var array{client_id: string, hostname: string, user_agent: string}
* @var array{
* client_id: string,
* hostname: string,
* user_agent: string,
* heartbeat_interval: int|null,
* }
*/
private array $features;
@@ -41,6 +46,7 @@ abstract class Connection
string $clientId = null,
string $hostname = null,
string $userAgent = null,
int $heartbeatInterval = null,
) {
$this->address = $address;
@@ -48,6 +54,7 @@ abstract class Connection
'client_id' => $clientId ?? '',
'hostname' => $hostname ?? (static fn (mixed $host): string => \is_string($host) ? $host : '')(gethostname()),
'user_agent' => $userAgent ?? 'nsqphp/'.InstalledVersions::getPrettyVersion('nsq/nsq'),
'heartbeat_interval' => $heartbeatInterval,
];
$this->logger = $logger ?? new NullLogger();