Skip to content

Conversation

@greblov
Copy link
Contributor

@greblov greblov commented Feb 14, 2019

<?php
use Enqueue\Consumption\QueueConsumer;
use Enqueue\Consumption\Extension\ExitStatusExtension;

$exitStatusExtension = new ExitStatusExtension();

$fooExtension = new class implements StartExtensionInterface {
    public function onStart(Start $context) 
    {
        $context->interruptExecution(1); // set custom exit code
    }
}

/** @var QueueConsumer $consumer **/
$consumer->consume(new ChainExtension([
    $fooExtension
    $exitStatusExtension
]));

exit($exitStatusExtension->getExitStatus());

return $this->exitStatus;
}

public function isExitStatusCaptured(): bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this

$consumer->consume(new ChainExtension($extensions));

return null;
return $captureExitStatusExtension->getExitStatus();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is another consume command that has to be adjusted too
you should add a test for command too.

use Enqueue\Consumption\Context\End;
use Enqueue\Consumption\EndExtensionInterface;

class CaptureExitStatusExtension implements EndExtensionInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExitStatusExtension

@makasim makasim changed the title 759 change command exit status [consumption] Add ability to change process exit status from within queue consumer extension Feb 14, 2019
@makasim makasim merged commit cb084ea into php-enqueue:master Feb 14, 2019
@makasim
Copy link
Member

makasim commented Feb 14, 2019

fixes #759

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants