Skip to content

Commit

Permalink
Merge pull request #12 from spiral/fix/pause-state
Browse files Browse the repository at this point in the history
Fixes problem with queue "is paused" state checking
  • Loading branch information
butschster authored Jan 19, 2022
2 parents 3ca9661 + 5cf96be commit de1c101
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ public function resume(): void
* {@inheritDoc}
*/
public function isPaused(): bool
{
$stat = $this->getPipelineStat();

return $stat !== null && ! $stat->getReady();
}

private function createRPCConnection(): RPCInterface
{
$env = Environment::fromGlobals();

return RPC::create($env->getRPCAddress());
}

public function getPipelineStat(): ?Stat
{
try {
/** @var Stats $stats */
Expand All @@ -214,20 +228,10 @@ public function isPaused(): bool
/** @var Stat $stat */
foreach ($stats->getStats() as $stat) {
if ($stat->getPipeline() === $this->name) {
return $stat->getActive() !== 0;
return $stat;
}
}

return false;
}

/**
* @return RPCInterface
*/
private function createRPCConnection(): RPCInterface
{
$env = Environment::fromGlobals();

return RPC::create($env->getRPCAddress());
return null;
}
}

0 comments on commit de1c101

Please sign in to comment.