optimize auto reload uvicornserver load new vector libs if changed by py

This commit is contained in:
team2
2026-02-26 16:00:24 +01:00
parent 052ff55eda
commit deba7cd06f
4 changed files with 280 additions and 67 deletions

View File

@@ -106,6 +106,9 @@ final class IndexMetaManager
$this->atomicWriteJson($this->runtimePath, $payload);
}
/**
* Für Chunk-Rebuilds (harte Zahl + Commit-Timestamp).
*/
public function updateRuntimeStats(int $chunkCount): void
{
$this->ensureRuntimeFileExists();
@@ -118,7 +121,40 @@ final class IndexMetaManager
$this->atomicWriteJson($this->runtimePath, $payload);
}
public function getRuntimeChunkCount(): int
/**
* Enterprise-Commit-Marker für alles, was einen Reload im Vector-Service erfordern soll,
* ohne dass zwingend chunk_count aktualisiert werden kann (z.B. Tag-Rebuild).
*
* Beispiel:
* touchRuntime(['last_tags_rebuild_at' => DATE_ATOM])
*/
public function touchRuntime(array $extra = []): void
{
$this->ensureRuntimeFileExists();
$current = $this->readRuntime() ?? [];
// Grundschema absichern
if (!isset($current['chunk_count'])) {
$current['chunk_count'] = 0;
}
$payload = array_merge(
$current,
$extra,
[
// Commit-Marker IMMER setzen/überschreiben
'last_rebuild_at' => (new \DateTimeImmutable())->format(DATE_ATOM),
]
);
$this->atomicWriteJson($this->runtimePath, $payload);
}
/**
* Runtime-Info lesen (z.B. für Tests, Debug, Polling).
*/
public function readRuntime(): ?array
{
$this->ensureRuntimeFileExists();
@@ -127,9 +163,25 @@ final class IndexMetaManager
true
);
return is_array($data) ? $data : null;
}
public function getRuntimeChunkCount(): int
{
$data = $this->readRuntime();
return (int)($data['chunk_count'] ?? 0);
}
public function getRuntimeLastRebuildAt(): ?string
{
$data = $this->readRuntime();
$v = $data['last_rebuild_at'] ?? null;
return is_string($v) && $v !== '' ? $v : null;
}
// =====================================================
// INTERNAL ATOMIC JSON WRITE
// =====================================================