Skip to content

Commit

Permalink
feat: imp v2;
Browse files Browse the repository at this point in the history
  • Loading branch information
vitgrams committed Nov 27, 2024
1 parent 2423deb commit 9d84bcf
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,22 @@ protected function createApplication(): void
$app->make(Kernel::class)->bootstrap();
}

protected function mergeTempDocumentation(string $token): void
protected function mergeTempDocumentation(): void
{
$swaggerService = app(SwaggerService::class);

$handle = fopen(config('auto-doc.tmp_dir') . "/temp_documentation.json", 'c+');
$lockHandle = fopen(config('auto-doc.tmp_dir') . '/lock.lock', 'c+');

while (!flock($handle, LOCK_EX | LOCK_NB)) {
usleep(10);
}

$tmpDoc = file_get_contents(config('auto-doc.tmp_dir') . "/temp_documentation_{$token}.json");
$locked = false;

$prodDoc = json_decode(stream_get_contents($handle), true);
while (!$locked) {
$locked = flock($lockHandle, LOCK_EX | LOCK_NB);

$swaggerService->mergeOpenAPIDocs($prodDoc, json_decode($tmpDoc, true));
usleep(10);
}

$swaggerService->saveProductionData();

fclose($handle);
flock($lockHandle, LOCK_UN);
}
}

0 comments on commit 9d84bcf

Please sign in to comment.