Skip to content

Commit

Permalink
[1.x] Handles Telescope ingest (#151)
Browse files Browse the repository at this point in the history
* telescope ingest

* fix linting

* fix escaping

* formatting
  • Loading branch information
joedixon authored Apr 16, 2024
1 parent 371aefd commit bf6b6f8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/reverb.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
],
'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
],

],
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ parameters:
- "#\\(void\\) is used.#"
- "#Parameter \\$livewire of anonymous function has invalid type#"
- "#Class Laravel\\\\Pulse\\\\Pulse not found#"
- "#Class Laravel\\\\Telescope\\\\Contracts\\\\EntriesRepository not found#"
- "#Call to static method store\\(\\) on an unknown class Laravel\\\\Telescope\\\\Telescope#"
15 changes: 15 additions & 0 deletions src/Servers/Reverb/Console/Commands/StartServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function handle(): void
$this->ensureStaleConnectionsAreCleaned($loop);
$this->ensureRestartCommandIsRespected($server, $loop, $host, $port);
$this->ensurePulseEventsAreCollected($loop, $config['pulse_ingest_interval']);
$this->ensureTelescopeEntriesAreCollected($loop, $config['telescope_ingest_interval'] ?? 15);

$this->components->info('Starting '.($server->isSecure() ? 'secure ' : '')."server on {$host}:{$port}".(($hostname && $hostname !== $host) ? " ({$hostname})" : ''));

Expand Down Expand Up @@ -145,6 +146,20 @@ protected function ensurePulseEventsAreCollected(LoopInterface $loop, int $inter
});
}

/**
* Schedule Telescope to store entries if enabled.
*/
protected function ensureTelescopeEntriesAreCollected(LoopInterface $loop, int $interval): void
{
if (! class_exists(\Laravel\Telescope\Telescope::class)) {
return;
}

$loop->addPeriodicTimer($interval, function () {
\Laravel\Telescope\Telescope::store($this->laravel->make(\Laravel\Telescope\Contracts\EntriesRepository::class));
});
}

/**
* Get the list of signals handled by the command.
*/
Expand Down

0 comments on commit bf6b6f8

Please sign in to comment.