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

@@ -38,6 +38,7 @@
"symfony/property-access": "7.1.*",
"symfony/property-info": "7.1.*",
"symfony/runtime": "7.1.*",
"symfony/scheduler": "7.1.*",
"symfony/security-bundle": "7.1.*",
"symfony/serializer": "7.1.*",
"symfony/stimulus-bundle": "^2.18",

82
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "af922427284c3d73551bff22f6f35ecd",
"content-hash": "3a109ea711d0d990a1fbb9c65d71767c",
"packages": [
{
"name": "api-platform/core",
@@ -6625,6 +6625,86 @@
],
"time": "2024-05-31T14:55:39+00:00"
},
{
"name": "symfony/scheduler",
"version": "v7.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/scheduler.git",
"reference": "024c63fb700453cb53c2d9f71e6868288b0b6fe9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/scheduler/zipball/024c63fb700453cb53c2d9f71e6868288b0b6fe9",
"reference": "024c63fb700453cb53c2d9f71e6868288b0b6fe9",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/clock": "^6.4|^7.0"
},
"require-dev": {
"dragonmantank/cron-expression": "^3.1",
"symfony/cache": "^6.4|^7.0",
"symfony/console": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0",
"symfony/lock": "^6.4|^7.0",
"symfony/messenger": "^6.4|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Scheduler\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sergey Rabochiy",
"email": "upyx.00@gmail.com"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides scheduling through Symfony Messenger",
"homepage": "https://symfony.com",
"keywords": [
"cron",
"schedule",
"scheduler"
],
"support": {
"source": "https://github.com/symfony/scheduler/tree/v7.1.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-06-02T15:49:12+00:00"
},
{
"name": "symfony/security-bundle",
"version": "v7.1.2",

View File

@@ -24,6 +24,7 @@ framework:
Symfony\Component\Mailer\Messenger\SendEmailMessage: async
Symfony\Component\Notifier\Message\ChatMessage: async
Symfony\Component\Notifier\Message\SmsMessage: async
App\Message\UpdateRdapServers: async
# Route your messages to the transports
# 'App\Message\YourMessage': async

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