Skip to content

Commit 1396cc5

Browse files
authored
Merge pull request #331 from patchlevel/add-missing-config-docs
Add more config documentations:
2 parents 2d92b84 + 4900820 commit 1396cc5

1 file changed

Lines changed: 175 additions & 0 deletions

File tree

docs/configuration.md

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,53 @@ If you are using the [doctrine-test-bundle](https://github.com/dmaicher/doctrine
362362
you can use the `static_in_memory` store for testing.
363363
:::
364364

365+
### Retry Strategies
366+
367+
If a subscriber throws an error, the subscription engine can retry it later instead of leaving it in an error state.
368+
You can define one or more named retry strategies and choose which one is used by default.
369+
370+
```yaml
371+
patchlevel_event_sourcing:
372+
subscription:
373+
retry_strategies:
374+
default:
375+
type: clock_based
376+
options:
377+
base_delay: 5
378+
delay_factor: 2
379+
max_attempts: 5
380+
no_retry:
381+
type: no_retry
382+
default_retry_strategy: default
383+
```
384+
385+
The following strategy types are available:
386+
387+
- `clock_based`: retries with an increasing delay based on the clock. Configurable via `base_delay` (seconds),
388+
`delay_factor` and `max_attempts`.
389+
- `no_retry`: never retries.
390+
- `custom`: use your own strategy. You need to set the `service` id to a service implementing the
391+
`Patchlevel\EventSourcing\Subscription\RetryStrategy\RetryStrategy` interface.
392+
393+
```yaml
394+
patchlevel_event_sourcing:
395+
subscription:
396+
retry_strategies:
397+
my_strategy:
398+
type: custom
399+
service: my_retry_strategy_service
400+
default_retry_strategy: my_strategy
401+
```
402+
403+
:::note
404+
If you don't configure anything, a `default` (`clock_based`) and a `no_retry` strategy are registered and `default` is used.
405+
:::
406+
407+
:::tip
408+
You can select the retry strategy per subscriber. If you want to learn more about retry strategies, read the
409+
[library documentation](/docs/event-sourcing/latest/subscription/#retry-strategy).
410+
:::
411+
365412
### Catch Up
366413

367414
If aggregates are used in the processors and new events are generated there,
@@ -375,6 +422,15 @@ patchlevel_event_sourcing:
375422
subscription:
376423
catch_up: true
377424
```
425+
426+
You can also limit how many messages are processed per catch up run with the `limit` option.
427+
428+
```yaml
429+
patchlevel_event_sourcing:
430+
subscription:
431+
catch_up:
432+
limit: 100
433+
```
378434
### Throw on Error
379435

380436
You can activate the `throw_on_error` option to throw an exception if a subscription engine run has an error.
@@ -400,6 +456,24 @@ patchlevel_event_sourcing:
400456
subscription:
401457
run_after_aggregate_save: true
402458
```
459+
460+
You can also restrict which subscribers are run and limit how many messages are processed.
461+
Use `ids` and `groups` to only run specific subscribers and `limit` to cap the number of processed messages.
462+
463+
```yaml
464+
patchlevel_event_sourcing:
465+
subscription:
466+
run_after_aggregate_save:
467+
ids:
468+
- 'profile_projection'
469+
groups:
470+
- 'default'
471+
limit: 100
472+
```
473+
474+
:::note
475+
If `ids` and `groups` are empty, all subscribers are run.
476+
:::
403477
### Auto Setup
404478

405479
If you want to automatically setup the subscription engine, you can activate this option.
@@ -415,6 +489,21 @@ patchlevel_event_sourcing:
415489
This works only before each http requests and not if you use the console commands.
416490
:::
417491

492+
You can restrict the setup to specific subscribers with `ids` and `groups`.
493+
With `exclude_url` you can define a regex for urls that should not trigger the auto setup.
494+
By default the symfony internal routes (`^/_(wdt|profiler|error)`) are excluded.
495+
496+
```yaml
497+
patchlevel_event_sourcing:
498+
subscription:
499+
auto_setup:
500+
ids:
501+
- 'profile_projection'
502+
groups:
503+
- 'default'
504+
exclude_url: '^/_(wdt|profiler|error)'
505+
```
506+
418507
### Rebuild After File Change
419508

420509
If you want to rebuild the subscription engine after a file change, you can activate this option.
@@ -434,6 +523,17 @@ This works only before each http requests and not if you use the console command
434523
This is using the cache system to store the latest file change time. You can change the cache pool with the `cache_pool` option.
435524
:::
436525

526+
With `exclude_url` you can define a regex for urls that should not trigger the rebuild.
527+
By default the symfony internal routes (`^/_(wdt|profiler|error)`) are excluded.
528+
529+
```yaml
530+
patchlevel_event_sourcing:
531+
subscription:
532+
rebuild_after_file_change:
533+
cache_pool: cache.app
534+
exclude_url: '^/_(wdt|profiler|error)'
535+
```
536+
437537
### Gap Detection
438538

439539
Depending on the database you are using for the eventstore it may be happening that your subscriptions are skipping some
@@ -502,6 +602,18 @@ patchlevel_event_sourcing:
502602
You can find out more about the command bus and the aggregate handlers [here](/docs/event-sourcing/latest/command-bus).
503603
:::
504604

605+
### Register Aggregate Handlers
606+
607+
By default the aggregate command handlers are automatically registered for the configured messenger bus.
608+
If you want to register them yourself, you can disable this behaviour.
609+
610+
```yaml
611+
patchlevel_event_sourcing:
612+
command_bus:
613+
service: command.bus
614+
register_aggregate_handlers: false
615+
```
616+
505617
### Instant Retry
506618

507619
You can define the default instant retry configuration for the command bus.
@@ -669,6 +781,26 @@ patchlevel_event_sourcing:
669781
default:
670782
service: event_sourcing.cache
671783
```
784+
785+
You can also choose the store type. The following types are available:
786+
787+
- `psr6` *default*
788+
- `psr16`
789+
- `custom`
790+
791+
```yaml
792+
patchlevel_event_sourcing:
793+
snapshot_stores:
794+
default:
795+
type: psr16
796+
service: event_sourcing.cache
797+
```
798+
799+
:::note
800+
If you use the `custom` type, the `service` has to implement the
801+
`Patchlevel\EventSourcing\Snapshot\SnapshotStore` interface.
802+
:::
803+
672804
Finally, you have to tell the aggregate that it should use this snapshot store.
673805

674806
```php
@@ -719,6 +851,49 @@ patchlevel_event_sourcing:
719851
You can find out more about personal data [here](/docs/event-sourcing/latest/personal-data).
720852
:::
721853

854+
## Hydrator
855+
856+
You can enable the extension based hydrator, which replaces the legacy metadata hydrator.
857+
858+
```yaml
859+
patchlevel_event_sourcing:
860+
hydrator: ~
861+
```
862+
863+
### Default Lazy
864+
865+
You can enable lazy hydration by default. This means that values are only hydrated when they are accessed.
866+
867+
```yaml
868+
patchlevel_event_sourcing:
869+
hydrator:
870+
default_lazy: true
871+
```
872+
873+
### Cryptography
874+
875+
The hydrator brings its own cryptography extension to encrypt and decrypt personal data.
876+
You can enable it and optionally choose the algorithm.
877+
878+
```yaml
879+
patchlevel_event_sourcing:
880+
hydrator:
881+
cryptography:
882+
enabled: true
883+
algorithm: 'aes-256-gcm'
884+
```
885+
886+
### Lifecycle
887+
888+
You can enable the lifecycle extension to run lifecycle hooks during hydration.
889+
890+
```yaml
891+
patchlevel_event_sourcing:
892+
hydrator:
893+
lifecycle:
894+
enabled: true
895+
```
896+
722897
## Clock
723898

724899
The clock is used to return the current time as DateTimeImmutable.

0 commit comments

Comments
 (0)