Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
laravel
/
pulse
/
src
/
Commands
:
WorkCommand.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Laravel\Pulse\Commands; use Carbon\CarbonImmutable; use Illuminate\Console\Command; use Illuminate\Support\Sleep; use Laravel\Pulse\Pulse; use Laravel\Pulse\Support\CacheStoreResolver; use Symfony\Component\Console\Attribute\AsCommand; /** * @internal */ #[AsCommand(name: 'pulse:work')] class WorkCommand extends Command { /** * The command's signature. * * @var string */ public $signature = 'pulse:work {--stop-when-empty : Stop when the stream is empty}'; /** * The command's description. * * @var string */ public $description = 'Process incoming Pulse data from the ingest stream'; /** * Handle the command. */ public function handle( Pulse $pulse, CacheStoreResolver $cache, ): int { $lastRestart = $cache->store()->get('laravel:pulse:restart'); $lastTrimmedStorageAt = CarbonImmutable::now()->startOfMinute(); while (true) { $now = CarbonImmutable::now(); if ($lastRestart !== $cache->store()->get('laravel:pulse:restart')) { return self::SUCCESS; } $pulse->digest(); if ($now->subMinutes(10)->greaterThan($lastTrimmedStorageAt)) { $pulse->trim(); $lastTrimmedStorageAt = $now; } if ($this->option('stop-when-empty')) { return self::SUCCESS; } Sleep::for(1)->second(); } } }