Skip to content

Commit

Permalink
feat: add new method: Queue::status()
Browse files Browse the repository at this point in the history
build: [release]
  • Loading branch information
lots0logs committed Nov 18, 2024
1 parent be1e780 commit 299b88b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' );
Expand Down

0 comments on commit 299b88b

Please sign in to comment.