And persistent via Doctrine ORM implementation
Install via Composer:
composer require sbooker/command-bus
Enpoints may use transactions. Strongly recommends use Sbooker/TransactionManager for it.
You need to make sure that firstly do all checks are and throws exceptions.
And only then mutates state of entities.
Build-in realization persistence layer of command bus require doctrine/dbal:^3.8 and database supports SELECT FOR UPDATE SKIP LOCKED (MySQL 8.0+, PostgreSQL 9.5+)
Install suggest libraries:
composer require sbooker/doctrine-enumerable-type \
sbooker/doctrine-transaction-handler \
ramsey/uuid-doctrine \
doctrine/dbal:^3.8
To use default configuration configure as bellow:
### config/packages/sbooker_command_bus.yaml
doctrine:
dbal:
types:
command_status: Sbooker\CommandBus\Infrastructure\Persistence\Mapping\StatusType
orm:
mappings:
SbookerCommands:
type: xml
prefix: Sbooker\CommandBus
dir: '%kernel.project_dir%/vendor/sbooker/command-bus/src/Infrastructure/Persistence/Mapping'
is_bundle: false
services:
Sbooker\CommandBus\CommandBus:
class: Sbooker\CommandBus\PersistentCommandBus
arguments:
- '@Sbooker\CommandBus\Normalizer'
- '@Sbooker\TransactionManager\TransactionManager'
- '@Sbooker\CommandBus\ReadStorage'
Sbooker\CommandBus\Normalizer:
class: Sbooker\CommandBus\Normalization\SymfonySerializerNormalizer
arguments:
- '@Sbooker\CommandBus\NameGiver'
- '@serializer'
Sbooker\CommandBus\Denormalizer:
class: Sbooker\CommandBus\Normalization\SymfonySerializerDenormalizer
arguments:
- '@Sbooker\CommandBus\NameGiver'
- '@serializer'
Sbooker\CommandBus\Registry:
class: Sbooker\CommandBus\Registry\Containerized\ContainerizedRegistry
arguments:
- '@command_bus.registry.endpoint_container'
- '@command_bus.registry.timeout_calculator_container'
command_bus.registry.endpoint_container:
class: Sbooker\CommandBus\Registry\Containerized\ContainerAdapter
arguments:
- '@service_container'
- ~
-
## command name to endpoint map
command_bus.registry.timeout_calculator_container:
class: Sbooker\CommandBus\Registry\Containerized\ContainerAdapter
arguments:
- '@service_container'
- 'command_bus.timeout_calculator.default'
-
## command name to timeout calculator map
command_bus.timeout_calculator.default:
public: true
class: Sbooker\CommandBus\TimeoutCalculator\Fix
arguments:
- 1
- 3
command_bus.timeout_calculator.external:
public: true
class: Sbooker\CommandBus\TimeoutCalculator\BinExp
arguments:
- 10
Sbooker\CommandBus\NameGiver:
class: Sbooker\CommandBus\NameGiver\ClassNameMap
arguments:
-
## FQCN to command name map
Sbooker\CommandBus\ReadStorage:
alias: Sbooker\CommandBus\Infrastructure\Persistence\DoctrineRepository
Sbooker\CommandBus\Infrastructure\Persistence\DoctrineRepository:
class: Sbooker\CommandBus\Infrastructure\Persistence\DoctrineRepository
factory: [ '@doctrine', getRepository ]
arguments:
- Sbooker\CommandBus\Command
See LICENSE file.