@@ -299,7 +299,7 @@ final class DoStuffSubscriber
299299You can provide your own argument resolvers by implementing the ` ArgumentResolver ` interface.
300300This can be useful for providing direct access to custom headers or other data.
301301
302- ### Setup and Teardown
302+ ### Setup
303303
304304Subscribers can have one ` setup ` method that is executed when the subscription is created.
305305For this there is the attributes ` Setup ` . The method name itself doesn't matter.
@@ -377,16 +377,20 @@ final class ProfileProjector
377377
378378!!! warning
379379
380- A teardown can only be performed for a subscription if the subscriber with that subscriber ID still exists.
380+ A teardown can only be performed for a subscription if the code for the subscriber with that subscriber ID still exists.
381+ A another option is to use the `Cleanup` option.
381382
382383!!! note
383384
384385 You can not mix the `cleanup` method with the `teardown` method.
385386
386387### Cleanup
387388
388- The cleanup option allows you to delete the subscription from the database after the subscription has finished.
389- This is especially useful for projectors,
389+ Alternativ, you can use a ` cleanup ` method for cleanup tasks.
390+ Unlike Teardown, this method is called when the subscription is created.
391+ The tasks are then saved in the Subscription Store.
392+ When removing the subscription, the subscriber is not necessary anymore,
393+ as the cleanup can be performed using the tasks in the store and an associated external handler.
390394
391395``` php
392396use Doctrine\DBAL\Connection;
@@ -416,9 +420,18 @@ final class ProfileProjector
416420
417421 You can not mix the `cleanup` method with the `teardown` method.
418422
423+ #### Dbal Cleanup Tasks
424+
425+ Default, we provide the following cleanup tasks for ` doctrine/dbal ` :
426+
427+ | Task | Description |
428+ | -----------------| ------------------------------|
429+ | ` DropIndexTask ` | Drops an index from a table. |
430+ | ` DropTableTask ` | Drops a table. |
431+
419432!!! tip
420433
421- You can create your own cleanup tasks and add them to the array .
434+ You can create your own cleanup tasks and handler .
422435 For more information, see [Cleanup Handler](#cleanup-handler).
423436
424437### On Failed
@@ -998,11 +1011,9 @@ $retryStrategyRepository = new RetryStrategyRepository([
9981011
9991012### Cleanup Handler
10001013
1001- You can also create your own cleanup tasks.
1002- The subscription engine will call the method ` __invoke ` on the task object.
1003- For example, you can create a task that drops a collection from a MongoDB database.
1004-
1005- First, create a task class, that holds the collection name.
1014+ You can also create your own cleanup tasks with associated handlers.
1015+ First, create a task class that has all necessary information for the task.
1016+ In our example, we create a task that deletes a collection from MongoDB.
10061017
10071018``` php
10081019final class DropCollection {
@@ -1016,7 +1027,8 @@ final class DropCollection {
10161027
10171028 The task class must be serializable. It will be stored in the subscription store.
10181029
1019- Then create a handler that supports this task.
1030+ The next step is to create a handler for the task.
1031+ The handler must implement the ` CleanupHandler ` interface.
10201032
10211033``` php
10221034use MongoDb\Database;
@@ -1041,7 +1053,8 @@ final class MongodbCleanupHandler implements CleanupHandler {
10411053}
10421054```
10431055
1044- Last step, you need to add the handler to the ` DefaultCleaner ` , that is used by the subscription engine.
1056+ Lastly, we have to add the new handler to ` DefaultCleaner ` ,
1057+ which is responsible for cleaning up subscriptions.
10451058
10461059``` php
10471060use Patchlevel\EventSourcing\Subscription\Cleanup\DefaultCleaner;
@@ -1052,6 +1065,10 @@ $cleaner = new DefaultCleaner([
10521065]);
10531066```
10541067
1068+ !!! warning
1069+
1070+ You need to pass the Cleaner to the Subscription Engine.
1071+
10551072### Subscriber Accessor
10561073
10571074The subscriber accessor repository is responsible for providing the subscribers to the subscription engine.
@@ -1105,7 +1122,7 @@ $subscriptionEngine = new DefaultSubscriptionEngine(
11051122 $logger, // optional
11061123 new DefaultCleaner([
11071124 new DbalCleanupHandler($projectionConnection)
1108- ]), // required, if you want to use the cleanup feature
1125+ ]), // optional but required if you want to use the cleanup feature
11091126);
11101127```
11111128### Catch up Subscription Engine
0 commit comments