1 | <?php |
||
14 | class EventStream |
||
15 | { |
||
16 | /** |
||
17 | * @var Connection |
||
18 | */ |
||
19 | protected $connection; |
||
20 | |||
21 | /** |
||
22 | * @var SerializerInterface |
||
23 | */ |
||
24 | protected $payloadSerializer; |
||
25 | |||
26 | /** |
||
27 | * @var SerializerInterface |
||
28 | */ |
||
29 | protected $metadataSerializer; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $tableName; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | protected $startId; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $lastProcessedId; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $cdbid; |
||
50 | |||
51 | /** |
||
52 | * @var EventStreamDecoratorInterface |
||
53 | */ |
||
54 | private $domainEventStreamDecorator; |
||
55 | |||
56 | /** |
||
57 | * @param Connection $connection |
||
58 | * @param SerializerInterface $payloadSerializer |
||
59 | * @param SerializerInterface $metadataSerializer |
||
60 | * @param string $tableName |
||
61 | */ |
||
62 | public function __construct( |
||
74 | |||
75 | /** |
||
76 | * @param int $startId |
||
77 | * @return EventStream |
||
78 | */ |
||
79 | public function withStartId($startId) |
||
80 | { |
||
81 | if (!is_int($startId)) { |
||
82 | throw new \InvalidArgumentException('StartId should have type int.'); |
||
83 | } |
||
84 | |||
85 | if ($startId <= 0) { |
||
86 | throw new \InvalidArgumentException('StartId should be higher than 0.'); |
||
87 | } |
||
88 | |||
89 | $c = clone $this; |
||
90 | $c->startId = $startId; |
||
91 | return $c; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @param string $cdbid |
||
96 | * @return EventStream |
||
97 | */ |
||
98 | public function withCdbid($cdbid) |
||
112 | |||
113 | /** |
||
114 | * @param EventStreamDecoratorInterface $domainEventStreamDecorator |
||
115 | * @return EventStream |
||
116 | */ |
||
117 | public function withDomainEventStreamDecorator(EventStreamDecoratorInterface $domainEventStreamDecorator) |
||
123 | |||
124 | public function __invoke() |
||
159 | |||
160 | /** |
||
161 | * @return int |
||
162 | */ |
||
163 | public function getLastProcessedId() |
||
167 | |||
168 | /** |
||
169 | * The load statement can no longer be 'cached' because of using the query |
||
170 | * builder. The query builder requires all parameters to be set before |
||
171 | * using the execute command. The previous solution used the prepare |
||
172 | * statement on the connection, this did not require all parameters to be |
||
173 | * set up front. |
||
174 | * |
||
175 | * @return Statement |
||
176 | * @throws DBALException |
||
177 | */ |
||
178 | protected function prepareLoadStatement() |
||
196 | |||
197 | /** |
||
198 | * @param $row |
||
199 | * @return DomainMessage |
||
200 | */ |
||
201 | private function deserializeEvent($row) |
||
211 | } |
||
212 |