brzuchal / saga
Saga Pattern Implementation
1.x-dev
2023-03-21 11:00 UTC
Requires
- php: ^8.1
- doctrine/dbal: ^3.3
- ramsey/uuid: ^4.3
- roave/better-reflection: ^5.0@dev
- symfony/serializer: ^6.0
Requires (Dev)
- doctrine/coding-standard: ^9.0
- phpunit/phpunit: ^9.1
- symfony/expression-language: ^5.4
- symfony/property-access: ^5.4
- vimeo/psalm: ^5
Suggests
- symfony/expression-language: Allows to evaluate association values from a message using a notation allowing to compile and evaluate expressions
- symfony/property-access: Allows to evaluate association values from a message object or embeded array using a simple string notation
This package is auto-updated.
Last update: 2024-10-15 04:22:44 UTC
README
Install
composer require brzuchal/saga
Usage
namespace App; use App\Events\OrderCreated; use Brzuchal\Saga\Mapping\Saga; use Brzuchal\Saga\Mapping\SagaMessageHandler; use Brzuchal\Saga\Mapping\SagaStart; #[Saga] class OrderProcessing { #[SagaStart,SagaMessageHandler(associationKey: 'orderId', property: 'id')] public function whenCreated(OrderCreated $event): void { // ... } }
Configuration
use App\OrderProcessing; use App\Events\OrderCreated; use Brzuchal\Saga\Mapping\AttributeMappingDriver; use Brzuchal\Saga\Mapping\SagaMetadataFactory; use Brzuchal\Saga\Repository\SimpleSagaRepositoryFactory; use Brzuchal\Saga\SagaManager; use Brzuchal\Saga\Store\InMemorySagaStore; $repositoryFactory = new SimpleSagaRepositoryFactory( new InMemorySagaStore(), new SagaMetadataFactory([new AttributeMappingDriver()]), ); $manager = new SagaManager($repositoryFactory->create(OrderProcessing::class)); $manager(new OrderCreated());