1 | <?php |
||
28 | class MongoEventStore implements EventStoreInterface, EventStoreManagementInterface, SnapshotEventStoreInterface, PartialEventStreamSupportInterface |
||
29 | { |
||
30 | /** |
||
31 | * @var LoggerInterface |
||
32 | */ |
||
33 | private $logger; |
||
34 | |||
35 | /** |
||
36 | * @var MongoTemplateInterface |
||
37 | */ |
||
38 | private $mongoTemplate; |
||
39 | |||
40 | /** |
||
41 | * @var SerializerInterface |
||
42 | */ |
||
43 | private $eventSerializer; |
||
44 | |||
45 | /** |
||
46 | * @var StorageStrategyInterface |
||
47 | */ |
||
48 | private $storageStrategy; |
||
49 | |||
50 | |||
51 | private $upcasterChain; |
||
52 | |||
53 | /** |
||
54 | * @param MongoTemplateInterface $mongoTemplate |
||
55 | * @param SerializerInterface $eventSerializer |
||
56 | * @param StorageStrategyInterface $storageStrategy |
||
57 | */ |
||
58 | 10 | function __construct( |
|
74 | |||
75 | |||
76 | /** |
||
77 | * Append the events in the given {@link DomainEventStreamInterface stream} to the event store. |
||
78 | * |
||
79 | * @param string $type The type descriptor of the object to store |
||
80 | * @param DomainEventStreamInterface $events The event stream containing the events to store |
||
81 | * @throws ConcurrencyException if an error occurs while storing the events in the event stream |
||
82 | */ |
||
83 | 7 | public function appendEvents($type, DomainEventStreamInterface $events) |
|
112 | |||
113 | /** |
||
114 | * @param string $type |
||
115 | * @param string $identifier |
||
116 | * @return \Governor\Framework\Domain\DomainEventMessageInterface[] |
||
117 | */ |
||
118 | 4 | private function loadLastSnapshotEvent($type, $identifier) |
|
139 | |||
140 | /** |
||
141 | * Read the events of the aggregate identified by the given type and identifier that allow the current aggregate |
||
142 | * state to be rebuilt. Implementations may omit or replace events (e.g. by using snapshot events) from the stream |
||
143 | * for performance purposes. |
||
144 | * |
||
145 | * @param string $type The type descriptor of the object to retrieve |
||
146 | * @param mixed $identifier The unique aggregate identifier of the events to load |
||
147 | * @return DomainEventStreamInterface an event stream containing the events of the aggregate |
||
148 | * |
||
149 | * @throws EventStoreException if an error occurs while reading the events in the event stream |
||
150 | */ |
||
151 | 4 | public function readEvents($type, $identifier) |
|
183 | |||
184 | /** |
||
185 | * @return callable |
||
186 | */ |
||
187 | 6 | private function getCursorCallback() |
|
203 | |||
204 | /** |
||
205 | * Returns a Stream containing events for the aggregate identified by the given {@code type} and {@code |
||
206 | * identifier}, starting at the event with the given {@code firstSequenceNumber} (included) up to and including the |
||
207 | * event with given {@code lastSequenceNumber}. |
||
208 | * If no event with given {@code lastSequenceNumber} exists, the returned stream will simply read until the end of |
||
209 | * the aggregate's events. |
||
210 | * <p/> |
||
211 | * The returned stream will not contain any snapshot events. |
||
212 | * |
||
213 | * @param string $type The type identifier of the aggregate |
||
214 | * @param string $identifier The identifier of the aggregate |
||
215 | * @param int $firstSequenceNumber The sequence number of the first event to find |
||
216 | * @param int|null $lastSequenceNumber The sequence number of the last event in the stream |
||
217 | * @return DomainEventStreamInterface a Stream containing events for the given aggregate, starting at the given first sequence number |
||
218 | * @throws EventStreamNotFoundException |
||
219 | */ |
||
220 | 2 | public function readEventsWithinScn( |
|
244 | |||
245 | |||
246 | /** |
||
247 | * Loads all events available in the event store and calls |
||
248 | * {@link \Governor\Framework\EventStore\EventVisitorInterface::doWithEvent} |
||
249 | * for each event found. Events of a single aggregate are guaranteed to be ordered by their sequence number. |
||
250 | * <p/> |
||
251 | * Implementations are encouraged, though not required, to supply events in the absolute chronological order. |
||
252 | * <p/> |
||
253 | * Processing stops when the visitor throws an exception. |
||
254 | * |
||
255 | * @param EventVisitorInterface $visitor The visitor the receives each loaded event |
||
256 | * @param CriteriaInterface $criteria The criteria describing the events to select. |
||
257 | */ |
||
258 | 1 | public function visitEvents( |
|
292 | |||
293 | /** |
||
294 | * Returns a CriteriaBuilderInterface that allows the construction of criteria for this EventStore implementation |
||
295 | * |
||
296 | * @return CriteriaBuilderInterface a builder to create Criteria for this Event Store. |
||
297 | */ |
||
298 | public function newCriteriaBuilder() |
||
302 | |||
303 | /** |
||
304 | * Sets a logger instance on the object |
||
305 | * |
||
306 | * @param LoggerInterface $logger |
||
307 | * @return null |
||
308 | */ |
||
309 | public function setLogger(LoggerInterface $logger) |
||
313 | |||
314 | /** |
||
315 | * Append the given <code>snapshotEvent</code> to the snapshot event log for the given type <code>type</code>. The |
||
316 | * sequence number of the <code>snapshotEvent</code> must be equal to the sequence number of the last regular |
||
317 | * domain |
||
318 | * event that is included in the snapshot. |
||
319 | * <p/> |
||
320 | * Implementations may choose to prune snapshots upon appending a new snapshot, in order to minimize storage space. |
||
321 | * |
||
322 | * @param string $type The type of aggregate the event belongs to |
||
323 | * @param DomainEventMessageInterface $snapshotEvent The event summarizing one or more domain events for a specific aggregate. |
||
324 | * @throws ConcurrencyException |
||
325 | */ |
||
326 | 5 | public function appendSnapshotEvent( |
|
344 | |||
345 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.