diff --git a/agent/build/agent.phar b/agent/build/agent.phar index 02279700..d6507e19 100755 Binary files a/agent/build/agent.phar and b/agent/build/agent.phar differ diff --git a/agent/build/signature.txt b/agent/build/signature.txt index 2b8bda11..9da1af64 100644 --- a/agent/build/signature.txt +++ b/agent/build/signature.txt @@ -1 +1 @@ -859B5CB714BE47686CD645444022C0336586C814B1C783F48E8AD843750845E011E19E53D7CAC9C92382E1242D4A83933DF9A0686B5A9A6E0330D69100C8A047 +EEFAD35214A42F62A817D01F5805400DCA2E15A50631BEE1AFF51DED19103C51460A44D5D4F496521EA85EA3D1893CEF0311CEE55B13229DEFC770936B5783A5 diff --git a/agent/src/Ingest.php b/agent/src/Ingest.php index 6c48501a..f579f081 100644 --- a/agent/src/Ingest.php +++ b/agent/src/Ingest.php @@ -30,7 +30,7 @@ class Ingest */ private array $concurrentRequests = []; - private ?TimerInterface $sendBufferAfterDelayTimer = null; + private ?TimerInterface $digestDelayTimer = null; private StreamBuffer|NullBuffer $buffer; @@ -59,11 +59,7 @@ public function __construct( public function write(string $payload): void { if ($this->buffer->isNotEmpty() && $this->buffer->willExceedThresholdWith($payload)) { - if ($this->sendBufferAfterDelayTimer !== null) { - $this->loop->cancelTimer($this->sendBufferAfterDelayTimer); - - $this->sendBufferAfterDelayTimer = null; - } + $this->cancelDigestDelay(); $this->digest(); } @@ -71,16 +67,12 @@ public function write(string $payload): void $this->buffer->write($payload); if ($this->buffer->reachedThreshold()) { - if ($this->sendBufferAfterDelayTimer !== null) { - $this->loop->cancelTimer($this->sendBufferAfterDelayTimer); - - $this->sendBufferAfterDelayTimer = null; - } + $this->cancelDigestDelay(); $this->digest(); } elseif ($this->buffer->isNotEmpty()) { - $this->sendBufferAfterDelayTimer ??= $this->loop->addTimer($this->maxBufferDurationInSeconds, function () { - $this->sendBufferAfterDelayTimer = null; + $this->digestDelayTimer ??= $this->loop->addTimer($this->maxBufferDurationInSeconds, function () { + $this->digestDelayTimer = null; $this->digest(); }); @@ -92,9 +84,7 @@ public function write(string $payload): void */ public function forceDigest(): PromiseInterface { - if ($this->sendBufferAfterDelayTimer !== null) { - $this->loop->cancelTimer($this->sendBufferAfterDelayTimer); - } + $this->cancelDigestDelay(); if ($this->buffer->isNotEmpty()) { $this->digest(); @@ -233,4 +223,12 @@ private function parseResponse(ResponseInterface $response): array $refreshIn, ]; } + + private function cancelDigestDelay(): void + { + if ($this->digestDelayTimer !== null) { + $this->loop->cancelTimer($this->digestDelayTimer); + $this->digestDelayTimer = null; + } + } }