prooph / event-store-http-client

PHP 7.2 Event Store HTTP Client Implementation
BSD 3-Clause "New" or "Revised" License
25 stars 5 forks source link

ErrorException: Undefined variable: nextPosition when reading all events #48

Open morrislaptop opened 4 years ago

morrislaptop commented 4 years ago
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());
morrislaptop commented 4 years ago

Due to this line - https://github.com/prooph/event-store/blob/ae40e9982935c9d66b4c6ef63144f8a2a9c41d7c/src/AllEventsSlice.php#L40

morrislaptop commented 4 years ago

Ironic issue number 😆

prolic commented 4 years ago

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.