Skip to content

Commit

Permalink
Merge pull request #4 from MammatusPHP/app-should-close-consumer-on-s…
Browse files Browse the repository at this point in the history
…ignals

App should close consumer on signals
  • Loading branch information
WyriHaximus authored May 20, 2024
2 parents 6d39009 + 0078f3f commit cf4e1e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function run(string $className): int

await(all($promises));

$this->context->close();

return 0;
}

Expand Down
22 changes: 22 additions & 0 deletions src/LifeCycle/CloseContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Mammatus\Queue\LifeCycle;

use Interop\Queue\Context;
use Mammatus\LifeCycleEvents\Shutdown;
use WyriHaximus\Broadcast\Contracts\Listener;

final class CloseContext implements Listener
{
public function __construct(
private readonly Context $context,
) {
}

public function stop(Shutdown $event): void
{
$this->context->close();
}
}

0 comments on commit cf4e1e0

Please sign in to comment.