feat: make preloading of CIDR asynchronous at application startup

This commit is contained in:
Rekryt
2024-09-22 20:46:54 +03:00
parent 11952303cd
commit 6e42686fc7
3 changed files with 20 additions and 5 deletions

View File

@@ -44,6 +44,25 @@ final class Site {
$this->dnsHelper = new DNSHelper($dns);
}
/**
* @return void
*/
public function preload(): void {
$startTime = time();
App::getLogger()->notice('Preloading for ' . $this->name, ['started']);
if ($this->timeout) {
$this->cidr4 = SiteFactory::normalize(
IP4Helper::processCIDR($this->ip4, SiteFactory::normalize($this->cidr4)),
true
);
$this->cidr6 = SiteFactory::normalize(
IP6Helper::processCIDR($this->ip6, SiteFactory::normalize($this->cidr6)),
true
);
}
App::getLogger()->notice('Preloaded for ' . $this->name, ['finished', time() - $startTime]);
}
/**
* @return void
*/