Skip to content

Commit 406f903

Browse files
authored
Optimize logging and fix connection information in Consumer (#709)
* Optimize logging and fix connection information in Consumer * Optimize logging and handle connection loss in Consumer.php --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
1 parent 767bd0a commit 406f903

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Consumer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,20 @@ public function start(): void
9191
Coroutine::create(function () use ($context) {
9292
CoordinatorManager::until(Constants::WORKER_EXIT)->yield();
9393
$this->stop();
94-
$this->logger?->warning('[{connection}] Consumer stopped.', $context);
94+
$this->logger?->warning('[{connection}] Consumer exit.', $context);
9595
});
9696

9797
while (1) {
9898
if ($this->isStopped()) {
99+
$this->logger?->warning('[{connection}] Consumer stopped.', $context);
99100
break;
100101
}
101102

102103
try {
103104
$replication->consume();
104105
} catch (SocketException $e) {
105-
// todo: reconnect
106-
$this->logger?->debug('[{connection}] Connection lost, reconnected.', $context);
106+
$this->stop();
107+
$this->logger?->warning('[{connection}] Connection lost, will retry later.', $context);
107108
}
108109
}
109110
};

src/Monitor/HealthMonitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
class HealthMonitor
2626
{
27-
protected BinLogCurrent $binLogCurrent;
27+
protected ?BinLogCurrent $binLogCurrent = null;
2828

2929
protected int $monitorInterval = 10;
3030

0 commit comments

Comments
 (0)