feat: update RDAP server url every month

This commit is contained in:
Maël Gangloff
2024-07-18 20:20:08 +02:00
parent d4546ae027
commit 59a74f050d
6 changed files with 149 additions and 1 deletions

View 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,
// ) {
// }
}

View 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();
}
}

View 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);
}
}