Skip to content

Commit

Permalink
Log sending packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadyita committed Feb 22, 2024
1 parent d467cd7 commit e75d7c5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/BasicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,15 @@ public function read(): ?Package\In {
}

public function write(Package\Out $package): void {
$this->logger?->debug("Sending package {package}", [
"package" => $package,
]);
$binPackage = $package->toBinaryPackage();
if ($package instanceof Package\Out\RateLimited) {
$this->logger?->debug("Sending rate-limited package via bucket-queue");
$this->bucket->take(callback: fn () => $this->connection->write($binPackage->toBinary()));
} else {
$this->logger?->debug("Sending non-rate-limited package instantly");
$this->connection->write($binPackage->toBinary());
}
}
Expand Down

0 comments on commit e75d7c5

Please sign in to comment.