event-store-http-client
event-store-http-client copied to clipboard
ErrorException: Undefined variable: nextPosition when reading all events
trafficstars
use Prooph\EventStore\EndPoint;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStoreHttpClient\ConnectionSettings;
use Prooph\EventStore\UserCredentials;
use Prooph\EventStoreHttpClient\EventStoreConnectionFactory;
use Prooph\EventStore\Position;
$creds = new UserCredentials('admin', 'changeit');
$settings = new ConnectionSettings(
new EndPoint('localhost', '2113'),
'http',
$creds
);
$connection = EventStoreConnectionFactory::create($settings);
$from = Position::start();
do {
$slice = $connection->readAllEventsForward($from, 4096);
foreach ($slice->events() as $event) {
$event = $event->event();
var_dump("/streams/{$event->eventStreamId()}/{$event->eventNumber()}");
}
$from = $slice->nextPosition();
}
while (!$slice->isEndOfStream());
Due to this line - https://github.com/prooph/event-store/blob/ae40e9982935c9d66b4c6ef63144f8a2a9c41d7c/src/AllEventsSlice.php#L40
Ironic issue number 😆
You are subscribing to all events and reached end of stream. This is a known issue, see https://github.com/EventStore/EventStore/issues/1809. As long as this isn't fixed upstream, we could implement a workaround like described in this issue. Do you wanna give a try and submit a PR? I'm currently working on finalizing the async tcp client, so I probably won't get to this here quickly.