45
45
use Patchlevel \EventSourcing \Console \Command \WatchCommand ;
46
46
use Patchlevel \EventSourcing \Console \DoctrineHelper ;
47
47
use Patchlevel \EventSourcing \Cryptography \DoctrineCipherKeyStore ;
48
+ use Patchlevel \EventSourcing \DecisionModel \DecisionModelBuilder ;
49
+ use Patchlevel \EventSourcing \DecisionModel \EventAppender ;
50
+ use Patchlevel \EventSourcing \DecisionModel \StoreDecisionModelBuilder ;
51
+ use Patchlevel \EventSourcing \DecisionModel \StoreEventAppender ;
48
52
use Patchlevel \EventSourcing \EventBus \AttributeListenerProvider ;
49
53
use Patchlevel \EventSourcing \EventBus \Consumer ;
50
54
use Patchlevel \EventSourcing \EventBus \DefaultConsumer ;
70
74
use Patchlevel \EventSourcing \QueryBus \QueryBus ;
71
75
use Patchlevel \EventSourcing \Repository \DefaultRepositoryManager ;
72
76
use Patchlevel \EventSourcing \Repository \MessageDecorator \ChainMessageDecorator ;
77
+ use Patchlevel \EventSourcing \Repository \MessageDecorator \EventTagDecorator ;
73
78
use Patchlevel \EventSourcing \Repository \MessageDecorator \MessageDecorator ;
74
79
use Patchlevel \EventSourcing \Repository \MessageDecorator \SplitStreamDecorator ;
75
80
use Patchlevel \EventSourcing \Repository \RepositoryManager ;
80
85
use Patchlevel \EventSourcing \Schema \DoctrineSchemaListener ;
81
86
use Patchlevel \EventSourcing \Schema \DoctrineSchemaProvider ;
82
87
use Patchlevel \EventSourcing \Schema \SchemaDirector ;
88
+ use Patchlevel \EventSourcing \Serializer \AttributeEventTagExtractor ;
83
89
use Patchlevel \EventSourcing \Serializer \DefaultEventSerializer ;
84
90
use Patchlevel \EventSourcing \Serializer \Encoder \Encoder ;
85
91
use Patchlevel \EventSourcing \Serializer \Encoder \JsonEncoder ;
86
92
use Patchlevel \EventSourcing \Serializer \EventSerializer ;
93
+ use Patchlevel \EventSourcing \Serializer \EventTagExtractor ;
87
94
use Patchlevel \EventSourcing \Serializer \Upcast \Upcaster ;
88
95
use Patchlevel \EventSourcing \Serializer \Upcast \UpcasterChain ;
89
96
use Patchlevel \EventSourcing \Snapshot \Adapter \Psr16SnapshotAdapter ;
90
97
use Patchlevel \EventSourcing \Snapshot \Adapter \Psr6SnapshotAdapter ;
91
98
use Patchlevel \EventSourcing \Snapshot \DefaultSnapshotStore ;
92
99
use Patchlevel \EventSourcing \Snapshot \SnapshotStore ;
93
100
use Patchlevel \EventSourcing \Store \InMemoryStore ;
101
+ use Patchlevel \EventSourcing \Store \ReadOnlyStore ;
94
102
use Patchlevel \EventSourcing \Store \Store ;
95
103
use Patchlevel \EventSourcing \Store \StreamDoctrineDbalStore ;
96
- use Patchlevel \EventSourcing \Store \StreamReadOnlyStore ;
104
+ use Patchlevel \EventSourcing \Store \TaggableDoctrineDbalStore ;
97
105
use Patchlevel \EventSourcing \Subscription \Engine \CatchUpSubscriptionEngine ;
98
106
use Patchlevel \EventSourcing \Subscription \Engine \DefaultSubscriptionEngine ;
99
107
use Patchlevel \EventSourcing \Subscription \Engine \GapResolverStoreMessageLoader ;
@@ -188,6 +196,7 @@ public function load(array $configs, ContainerBuilder $container): void
188
196
$ this ->configureMigration ($ config , $ container );
189
197
$ this ->configureValueResolver ($ container );
190
198
$ this ->configureStoreMigration ($ config , $ container );
199
+ $ this ->configureDCB ($ config , $ container );
191
200
}
192
201
193
202
/** @param Config $config */
@@ -230,6 +239,9 @@ private function configureSerializer(array $config, ContainerBuilder $container)
230
239
]);
231
240
232
241
$ container ->setAlias (HeadersSerializer::class, DefaultHeadersSerializer::class);
242
+
243
+ $ container ->register (AttributeEventTagExtractor::class);
244
+ $ container ->setAlias (EventTagExtractor::class, AttributeEventTagExtractor::class);
233
245
}
234
246
235
247
/** @param Config $config */
@@ -627,6 +639,10 @@ private function configureMessageDecorator(ContainerBuilder $container): void
627
639
->setArguments ([new Reference (EventMetadataFactory::class)])
628
640
->addTag ('event_sourcing.message_decorator ' );
629
641
642
+ $ container ->register (EventTagDecorator::class)
643
+ ->setArguments ([new Reference (EventTagExtractor::class)])
644
+ ->addTag ('event_sourcing.message_decorator ' );
645
+
630
646
$ container ->registerForAutoconfiguration (MessageDecorator::class)
631
647
->addTag ('event_sourcing.message_decorator ' );
632
648
@@ -721,7 +737,7 @@ private function configureStore(array $config, ContainerBuilder $container): voi
721
737
$ container ->setAlias (Store::class, StreamDoctrineDbalStore::class);
722
738
723
739
if ($ config ['store ' ]['read_only ' ]) {
724
- $ container ->register (StreamReadOnlyStore ::class)
740
+ $ container ->register (ReadOnlyStore ::class)
725
741
->setDecoratedService (Store::class)
726
742
->setArguments ([
727
743
new Reference ('.inner ' ),
@@ -731,6 +747,27 @@ private function configureStore(array $config, ContainerBuilder $container): voi
731
747
return ;
732
748
}
733
749
750
+ if ($ config ['store ' ]['type ' ] === 'dbal_taggable ' ) {
751
+ $ container ->register (TaggableDoctrineDbalStore::class)
752
+ ->setArguments ([
753
+ new Reference ('event_sourcing.dbal_connection ' ),
754
+ new Reference (EventSerializer::class),
755
+ new Reference (EventRegistry::class),
756
+ new Reference (HeadersSerializer::class),
757
+ new Reference ('event_sourcing.clock ' ),
758
+ $ config ['store ' ]['options ' ],
759
+ ])
760
+ ->addTag ('event_sourcing.doctrine_schema_configurator ' );
761
+
762
+ $ container ->setAlias (Store::class, TaggableDoctrineDbalStore::class);
763
+
764
+ if ($ config ['store ' ]['read_only ' ]) {
765
+ throw new InvalidArgumentException ('Taggable store does not support read only ' );
766
+ }
767
+
768
+ return ;
769
+ }
770
+
734
771
throw new InvalidArgumentException (sprintf ('Unknown store type "%s" ' , $ config ['store ' ]['type ' ]));
735
772
}
736
773
@@ -784,6 +821,20 @@ private function configureStoreMigration(array $config, ContainerBuilder $contai
784
821
return ;
785
822
}
786
823
824
+ if ($ config ['store ' ]['migrate_to_new_store ' ]['type ' ] === 'dbal_taggable ' ) {
825
+ $ container ->register ($ id , TaggableDoctrineDbalStore::class)
826
+ ->setArguments ([
827
+ new Reference ('event_sourcing.dbal_connection ' ),
828
+ new Reference (EventSerializer::class),
829
+ new Reference (HeadersSerializer::class),
830
+ new Reference ('event_sourcing.clock ' ),
831
+ $ config ['store ' ]['migrate_to_new_store ' ]['options ' ],
832
+ ])
833
+ ->addTag ('event_sourcing.doctrine_schema_configurator ' );
834
+
835
+ return ;
836
+ }
837
+
787
838
throw new InvalidArgumentException (sprintf ('Unknown store type "%s" ' , $ config ['store ' ]['type ' ]));
788
839
}
789
840
@@ -1135,6 +1186,31 @@ private function configureCryptography(array $config, ContainerBuilder $containe
1135
1186
$ container ->setAlias (PayloadCryptographer::class, PersonalDataPayloadCryptographer::class);
1136
1187
}
1137
1188
1189
+ /** @param Config $config */
1190
+ private function configureDCB (array $ config , ContainerBuilder $ container ): void
1191
+ {
1192
+ if (!$ config ['dcb ' ]['enabled ' ]) {
1193
+ return ;
1194
+ }
1195
+
1196
+ if ($ config ['store ' ]['type ' ] !== 'dbal_taggable ' ) {
1197
+ throw new InvalidArgumentException (
1198
+ 'DCB requires a taggable store, please use "dbal_taggable" as store type. ' ,
1199
+ );
1200
+ }
1201
+
1202
+ $ container ->register (StoreDecisionModelBuilder::class)
1203
+ ->setArguments ([new Reference (TaggableDoctrineDbalStore::class)]);
1204
+ $ container ->setAlias (DecisionModelBuilder::class, StoreDecisionModelBuilder::class);
1205
+
1206
+ $ container ->register (StoreEventAppender::class)
1207
+ ->setArguments ([
1208
+ new Reference (TaggableDoctrineDbalStore::class),
1209
+ new Reference (EventTagExtractor::class),
1210
+ ]);
1211
+ $ container ->setAlias (EventAppender::class, StoreEventAppender::class);
1212
+ }
1213
+
1138
1214
private function configureValueResolver (ContainerBuilder $ container ): void
1139
1215
{
1140
1216
$ container ->register (IdentifierValueResolver::class)
0 commit comments