舞曲工程师/事件酱-Prooph事件存储

此包已被弃用,不再维护。没有建议替代包。

一个连接到Prooph事件存储的EventSauce仓库

1.0.0 2020-07-12 11:42 UTC

This package is auto-updated.

Last update: 2023-05-15 19:50:06 UTC


README

这是一个连接到Prooph事件存储的EventSauce仓库。

为什么?

Prooph组件非常坚持你应该如何编写代码。

大部分的事件溯源组件现在已经被弃用,因此不能与仍在开发和维护的少数组件一起使用。

其中之一是维护到事件存储的接口。同时,它也提供了许多实现,如PDO事件存储数据库。此外,它们还提供了一些在事件存储中分割事件的有用策略。

因此,使用EventSauce进行事件溯源,使用Prooph进行事件存储是有用的。这个库正好提供了这样的功能。利用Prooph的综合持久层。

使用方法

function createInGeneral(): \EventSauce\EventSourcing\AggregateRootRepository
{
    /** @var \Prooph\EventStore\EventStore $eventStore */
    // Your Event Store has implementation has to use EventSauceMessageFactory to create messages from data!!

    $configuredEventStore = new ConfiguredEventStore($eventStore);
    return new ProophEventStoreRepository(\EventSauce\EventSourcing\AggregateRoot::class, $configuredEventStore);
}

function createConcreteExample(): \EventSauce\EventSourcing\AggregateRootRepository
{
    $eventStore = new \Prooph\EventStore\Pdo\PostgresEventStore(
        new EventSauceMessageFactory(), // Your Event Store has to use this class to create messages from data!!
        new \PDO('you know how to configure a PDO connection, don\'t you?'),
        new \Prooph\EventStore\Pdo\PersistenceStrategy\PostgresAggregateStreamStrategy()
    );

    $configuredEventStore = new ConfiguredEventStore($eventStore, true);
    return new ProophEventStoreRepository(\EventSauce\EventSourcing\AggregateRoot::class, $configuredEventStore);
}

function createFullConfig(): \EventSauce\EventSourcing\AggregateRootRepository
{
    /** @var \Prooph\EventStore\EventStore $eventStore */
    // Your Event Store has implementation has to use EventSauceMessageFactory to create messages from data!!

    $configuredEventStore = new ConfiguredEventStore($eventStore, false, ['stream_tag' => 'banana'], new
    \Prooph\EventStore\StreamName('lama'));
    return new ProophEventStoreRepository(\EventSauce\EventSourcing\AggregateRoot::class, $configuredEventStore, new
    \EventSauce\EventSourcing\CollectingMessageDispatcher(), new \EventSauce\EventSourcing\DefaultHeadersDecorator());
}