lthn.io/app/Core/Webhook/CronTrigger.php
Claude 41a90cbff8
feat: lthn.io API serving live chain data
Fixed: basePath self→static binding, namespace detection, event wiring,
SQLite cache, file cache driver. All Mod Boot classes converted to
$listens pattern for lifecycle event discovery.

Working endpoints:
- /v1/explorer/info — live chain height, difficulty, aliases
- /v1/explorer/stats — formatted chain statistics
- /v1/names/directory — alias directory grouped by type
- /v1/names/available/{name} — name availability check
- /v1/names/lookup/{name} — name details

Co-Authored-By: Charon <charon@lethean.io>
2026-04-03 17:17:42 +01:00

56 lines
1.4 KiB
PHP

<?php
/*
* Core PHP Framework
*
* Licensed under the European Union Public Licence (EUPL) v1.2.
* See LICENSE file for details.
*/
declare(strict_types=1);
namespace Core\Webhook;
use Core\Actions\Action;
use Core\Actions\Scheduled;
use Illuminate\Support\Facades\Http;
#[Scheduled(frequency: 'everyMinute', withoutOverlapping: true, runInBackground: true)]
class CronTrigger
{
use Action;
public function handle(): void
{
$triggers = config('webhook.cron_triggers', []);
foreach ($triggers as $product => $config) {
if (empty($config['base_url'])) {
continue;
}
$baseUrl = rtrim($config['base_url'], '/');
$key = $config['key'] ?? '';
$stagger = (int) ($config['stagger_seconds'] ?? 0);
$offset = (int) ($config['offset_seconds'] ?? 0);
if ($offset > 0) {
usleep($offset * 1_000_000);
}
foreach ($config['endpoints'] ?? [] as $i => $endpoint) {
if ($i > 0 && $stagger > 0) {
usleep($stagger * 1_000_000);
}
$url = $baseUrl.$endpoint.'?key='.$key;
try {
Http::timeout(30)->get($url);
} catch (\Throwable $e) {
logger()->warning("Cron trigger failed for {$product}{$endpoint}: {$e->getMessage()}");
}
}
}
}
}