From 299b88b19e3ac8b1d89aad13026a588948a6582c Mon Sep 17 00:00:00 2001 From: Dustin Falgout Date: Mon, 18 Nov 2024 14:16:30 -0600 Subject: [PATCH] feat: add new method: `Queue::status()` build: [release] --- src/Queue.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Queue.php b/src/Queue.php index 83e0a46..8f3eb05 100644 --- a/src/Queue.php +++ b/src/Queue.php @@ -91,6 +91,15 @@ public function put( callable $run, array $data ): string { return $job->id; } + public function status(): array { + return [ + 'running' => self::_dbTry( 'llen', $this->__running() ), + 'pending' => self::_dbTry( 'llen', $this->__pending() ), + 'completed' => self::_dbTry( 'llen', $this->__completed() ), + 'failed' => self::_dbTry( 'llen', $this->__failed() ), + ]; + } + public function take(): Job { if ( ! $job_id = self::$_DB->brpoplpush( $this->__pending(), $this->__running(), 600 ) ) { throw new \ErrorException( 'Timedout waiting for more work.' );