mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: update RDAP server url every month
This commit is contained in:
16
src/Message/UpdateRdapServers.php
Normal file
16
src/Message/UpdateRdapServers.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Message;
|
||||
|
||||
final class UpdateRdapServers
|
||||
{
|
||||
/*
|
||||
* Add whatever properties and methods you need
|
||||
* to hold the data for this message class.
|
||||
*/
|
||||
|
||||
// public function __construct(
|
||||
// public readonly string $name,
|
||||
// ) {
|
||||
// }
|
||||
}
|
||||
22
src/MessageHandler/UpdateRdapServersHandler.php
Normal file
22
src/MessageHandler/UpdateRdapServersHandler.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\MessageHandler;
|
||||
|
||||
use App\Message\UpdateRdapServers;
|
||||
use App\Service\RDAPService;
|
||||
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||
|
||||
#[AsMessageHandler]
|
||||
final readonly class UpdateRdapServersHandler
|
||||
{
|
||||
|
||||
public function __construct(private RDAPService $RDAPService)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function __invoke(UpdateRdapServers $message): void
|
||||
{
|
||||
$this->RDAPService->updateRDAPServers();
|
||||
}
|
||||
}
|
||||
28
src/Scheduler/UpdateRdapServersSchedule.php
Normal file
28
src/Scheduler/UpdateRdapServersSchedule.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Scheduler;
|
||||
|
||||
use App\Message\UpdateRdapServers;
|
||||
use Symfony\Component\Scheduler\Attribute\AsSchedule;
|
||||
use Symfony\Component\Scheduler\RecurringMessage;
|
||||
use Symfony\Component\Scheduler\Schedule;
|
||||
use Symfony\Component\Scheduler\ScheduleProviderInterface;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
||||
#[AsSchedule]
|
||||
final readonly class UpdateRdapServersSchedule implements ScheduleProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private CacheInterface $cache,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function getSchedule(): Schedule
|
||||
{
|
||||
return (new Schedule())
|
||||
->add(
|
||||
RecurringMessage::every('1 month', new UpdateRdapServers()),
|
||||
)->stateful($this->cache);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user