项目作者: event-engine

项目描述 :
Event Engine Prooph V7 Event Store Integration
高级语言: PHP
项目地址: git://github.com/event-engine/prooph-v7-event-store.git
创建时间: 2019-03-20T20:51:39Z
项目社区:https://github.com/event-engine/prooph-v7-event-store

开源协议:MIT License

下载


event-engine/prooph-v7-event-store

Event Engine Prooph V7 Event Store Bindings

Installation

  1. composer require event-engine/prooph-v7-event-store

Prooph Binding

tbd

InMemoryEventStore

tbd

FilesystemEventStore

A prooph v7 compatible FilesystemEventStore is included, too. It is meant to be used for demonstration purpose only (for example in a workshop).

  1. //Basic set up that's able to handle Prooph\Common\Messaging\DomainEvent
  2. $filesystemEventStore = new \EventEngine\Prooph\V7\EventStore\FilesystemEventStore(
  3. 'data/prooph.event_store.json',
  4. \JSON_PRETTY_PRINT
  5. // optional MessageFactory -> defaults to FQCNMessageFactory
  6. // optional MessageConverter -> defaults to NoOpMessageConverter
  7. );
  8. //Create an empty stream
  9. $filesystemEventStore->create(
  10. new \Prooph\EventStore\Stream(
  11. new \Prooph\EventStore\StreamName('event_stream'),
  12. new ArrayIterator()
  13. )
  14. );
  15. //Can also be used together with an InMemoryProjectionManager
  16. $projectionManager = new \EventEngine\Prooph\V7\EventStore\Projecting\InMemory\InMemoryProjectionManager(
  17. $filesystemEventStore,
  18. new \EventEngine\Persistence\InMemoryConnection()
  19. );
  20. $query = $projectionManager->createQuery();
  21. $query->fromStream('event_stream')
  22. ->whenAny(function (array $state, \Prooph\Common\Messaging\DomainEvent $event) {
  23. echo "{$event->messageName()} stored in event_stream\n";
  24. });
  25. $query->run();

Please Note: The combination of FilesystemEventStore and InMemoryProjectionManager has the drawback that projections only see events that are in the event store
at the time of running the projection. If other PHP processes add events to the store, those are first visible for the projection after restarting the PHP process and
running the projection again. We might add a FilesystemProjectionManager in the future, if needed.