Skip to content

Commit d3b4132

Browse files
fix: resolve config paths and Carbon timestamp parsing issues
- Fix routes/api.php to use correct config path for middleware - Fix WorkerHeartbeat::fromArray() to handle Unix timestamps correctly using Carbon::createFromTimestamp() for numeric values - Update remaining StorageManager references to RedisMetricsStore: - RecordTrendDataCommand - TrendAnalysisService - RecordQueueDepthHistoryAction - RecordThroughputHistoryAction Worker status endpoint now returns proper JSON with complete worker data. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a359c34 commit d3b4132

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

.claude/settings.local.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
"Bash(composer update:*)",
4040
"Bash(php:*)",
4141
"Bash(timeout 30 php:*)",
42-
"Bash(curl:*)"
42+
"Bash(curl:*)",
43+
"Bash(/Users/sylvester/Library/Application\\ Support/Herd/bin/php:*)",
44+
"Bash(/Users/sylvester/Library/Application Support/Herd/bin/php:*)",
45+
"Bash(composer dump-autoload:*)"
4346
],
4447
"deny": [],
4548
"ask": []

routes/api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
use PHPeek\LaravelQueueMetrics\Http\Controllers\WorkerController;
1515
use PHPeek\LaravelQueueMetrics\Http\Controllers\WorkerStatusController;
1616

17-
Route::prefix(config('queue-metrics.api.prefix', 'queue-metrics'))
18-
->middleware(config('queue-metrics.api.middleware', ['api']))
17+
Route::prefix('queue-metrics')
18+
->middleware(config('queue-metrics.middleware', ['api']))
1919
->group(function () {
2020
// Health check
2121
Route::get('/health', HealthCheckController::class)

src/Actions/RecordQueueDepthHistoryAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
use Carbon\Carbon;
88
use PHPeek\LaravelQueueMetrics\Config\QueueMetricsConfig;
9-
use PHPeek\LaravelQueueMetrics\Storage\StorageManager;
9+
use PHPeek\LaravelQueueMetrics\Support\RedisMetricsStore;
1010

1111
/**
1212
* Record queue depth to historical time series for trend analysis.
1313
*/
1414
final readonly class RecordQueueDepthHistoryAction
1515
{
1616
public function __construct(
17-
private StorageManager $storage,
17+
private RedisMetricsStore $storage,
1818
private QueueMetricsConfig $config,
1919
) {}
2020

src/Actions/RecordThroughputHistoryAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
use Carbon\Carbon;
88
use PHPeek\LaravelQueueMetrics\Config\QueueMetricsConfig;
9-
use PHPeek\LaravelQueueMetrics\Storage\StorageManager;
9+
use PHPeek\LaravelQueueMetrics\Support\RedisMetricsStore;
1010

1111
/**
1212
* Record throughput to historical time series for trend analysis.
1313
*/
1414
final readonly class RecordThroughputHistoryAction
1515
{
1616
public function __construct(
17-
private StorageManager $storage,
17+
private RedisMetricsStore $storage,
1818
private QueueMetricsConfig $config,
1919
) {}
2020

src/Console/RecordTrendDataCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHPeek\LaravelQueueMetrics\Actions\RecordQueueDepthHistoryAction;
99
use PHPeek\LaravelQueueMetrics\Actions\RecordThroughputHistoryAction;
1010
use PHPeek\LaravelQueueMetrics\Repositories\Contracts\WorkerHeartbeatRepository;
11-
use PHPeek\LaravelQueueMetrics\Storage\StorageManager;
11+
use PHPeek\LaravelQueueMetrics\Support\RedisMetricsStore;
1212

1313
/**
1414
* Record historical trend data for analysis.
@@ -23,7 +23,7 @@ public function __construct(
2323
private readonly WorkerHeartbeatRepository $workerHeartbeat,
2424
private readonly RecordQueueDepthHistoryAction $recordQueueDepth,
2525
private readonly RecordThroughputHistoryAction $recordThroughput,
26-
private readonly StorageManager $storage,
26+
private readonly RedisMetricsStore $storage,
2727
) {
2828
parent::__construct();
2929
}

src/DataTransferObjects/WorkerHeartbeat.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ public static function fromArray(array $data): self
5959
connection: $connection,
6060
queue: $queue,
6161
state: WorkerState::from($state),
62-
lastHeartbeat: is_string($lastHeartbeat) ? Carbon::parse($lastHeartbeat) : Carbon::now(),
63-
lastStateChange: isset($data['last_state_change']) && is_string($data['last_state_change'])
64-
? Carbon::parse($data['last_state_change'])
65-
: null,
62+
lastHeartbeat: is_numeric($lastHeartbeat) ? Carbon::createFromTimestamp((int) $lastHeartbeat) : (is_string($lastHeartbeat) ? Carbon::parse($lastHeartbeat) : Carbon::now()),
63+
lastStateChange: isset($data['last_state_change']) && is_numeric($data['last_state_change'])
64+
? Carbon::createFromTimestamp((int) $data['last_state_change'])
65+
: (isset($data['last_state_change']) && is_string($data['last_state_change']) ? Carbon::parse($data['last_state_change']) : null),
6666
currentJobId: is_string($currentJobId) ? $currentJobId : null,
6767
currentJobClass: is_string($currentJobClass) ? $currentJobClass : null,
6868
idleTimeSeconds: is_numeric($data['idle_time_seconds'] ?? 0.0) ? (float) ($data['idle_time_seconds'] ?? 0.0) : 0.0,

src/Services/TrendAnalysisService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace PHPeek\LaravelQueueMetrics\Services;
66

77
use Carbon\Carbon;
8-
use PHPeek\LaravelQueueMetrics\Storage\StorageManager;
8+
use PHPeek\LaravelQueueMetrics\Support\RedisMetricsStore;
99

1010
/**
1111
* Analyzes metrics trends over time for forecasting and insights.
1212
*/
1313
final readonly class TrendAnalysisService
1414
{
1515
public function __construct(
16-
private StorageManager $storage,
16+
private RedisMetricsStore $storage,
1717
) {}
1818

1919
/**

0 commit comments

Comments
 (0)