-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add subscription setup cli commands & skip setup in subscription run
- Loading branch information
1 parent
fe23cbc
commit 55e10ec
Showing
6 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Console\Command; | ||
|
||
use Patchlevel\EventSourcing\Console\OutputStyle; | ||
use Patchlevel\EventSourcing\Store\Store; | ||
use Patchlevel\EventSourcing\Store\SubscriptionStore; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
#[AsCommand( | ||
'event-sourcing:schema:subscription-setup', | ||
'setup subscription (pub/sub) for store', | ||
)] | ||
final class SchemaSubscriptionSetupCommand extends Command | ||
{ | ||
public function __construct( | ||
private readonly Store $store, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new OutputStyle($input, $output); | ||
|
||
if (!$this->store instanceof SubscriptionStore) { | ||
$io->error('store does not support subscriptions'); | ||
|
||
return 1; | ||
} | ||
|
||
if (!$this->store->supportSubscription()) { | ||
$io->error('store does not support subscriptions'); | ||
|
||
return 1; | ||
} | ||
|
||
$this->store->setupSubscription(); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Console\Command; | ||
|
||
use Patchlevel\EventSourcing\Console\OutputStyle; | ||
use Patchlevel\EventSourcing\Store\Store; | ||
use Patchlevel\EventSourcing\Store\SubscriptionStore; | ||
use Symfony\Component\Console\Attribute\AsCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
use function method_exists; | ||
|
||
#[AsCommand( | ||
'event-sourcing:schema:subscription-teardown', | ||
'teardown subscription (pub/sub) for store', | ||
)] | ||
final class SchemaSubscriptionTeardownCommand extends Command | ||
{ | ||
public function __construct( | ||
private readonly Store $store, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
$io = new OutputStyle($input, $output); | ||
|
||
if (!$this->store instanceof SubscriptionStore) { | ||
$io->error('store does not support subscriptions'); | ||
|
||
return 1; | ||
} | ||
|
||
if (!$this->store->supportSubscription()) { | ||
$io->error('store does not support subscriptions'); | ||
|
||
return 1; | ||
} | ||
|
||
if (method_exists($this->store, 'teardownSubscription')) { | ||
$this->store->teardownSubscription(); | ||
|
||
return 0; | ||
} | ||
|
||
$io->error('store does not support teardownSubscription'); | ||
|
||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters