Skip to content

Commit fb5c61e

Browse files
committed
Implement fix
1 parent e76f67d commit fb5c61e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/KubernetesCluster.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,22 +263,27 @@ protected function watchPath(string $path, Closure $callback, array $query = ['p
263263
*/
264264
protected function watchLogsPath(string $path, Closure $callback, array $query = ['pretty' => 1])
265265
{
266-
\var_dump("Starting0: " . \microtime(true));
267266
$sock = $this->createSocketConnection($this->getCallableUrl($path, $query));
268267

269268
$data = null;
270269

271-
\var_dump("Starting1: " . \microtime(true));
272-
while (($data = fgets($sock, 100)) == true) {
273-
\var_dump("Chunk part: " . \microtime(true));
274-
$call = call_user_func($callback, $data);
270+
$chunk = '';
271+
while (($data = fgets($sock, 64)) == true) {
272+
$chunk .= $data;
275273

276-
if (! is_null($call)) {
277-
fclose($sock);
274+
$separator = \strpos($chunk, "\n");
275+
if ($separator !== false) {
276+
$extra = \substr($chunk, $separator + \strlen("\n"));
277+
$chunk = \substr($chunk, 0, $separator);
278278

279-
unset($data);
279+
$call = call_user_func($callback, $data);
280+
if (!is_null($call)) {
281+
fclose($sock);
282+
unset($data);
283+
return $call;
284+
}
280285

281-
return $call;
286+
$chunk = $extra;
282287
}
283288
}
284289
}

0 commit comments

Comments
 (0)