Skip to content

Commit

Permalink
Merge pull request #3 from barryosull/feature/stop_stall_at_chunk_size
Browse files Browse the repository at this point in the history
Remove code that caused the stall
  • Loading branch information
Barry O Sullivan committed Mar 7, 2017
2 parents bba83d3 + a5cb696 commit 816dfd0
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/Sourced/Stream/AbstractStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abstract class AbstractStream
{
protected $limit;
protected $chunk_size;

/**
* @var Integer_
*/
Expand Down Expand Up @@ -45,32 +45,24 @@ protected function fetch()
$this->event_snapshots = new Collection();

$event_snapshot_schemas = $this->get_next_chunk();

foreach ($event_snapshot_schemas as $event_snapshot_schema) {
$snapshot_popo = json_decode($event_snapshot_schema->snapshot);
$this->event_snapshots->append($snapshot_popo);
}

$this->set_offset($event_snapshot_schemas);
}

abstract protected function get_next_chunk();

abstract protected function set_offset(array $event_snapshot_rows);

protected function is_unlimited()
{
return ($this->limit->equals(new Integer_(0)));
}

protected function has_more_chunks()
{
return (
$this->event_snapshots->count()->value() <
$this->chunk_size->value()
);
}

public function current()
{
return $this->event_snapshots->current();
Expand All @@ -80,10 +72,7 @@ public function next()
{
$this->event_snapshots->next();

if(
!$this->event_snapshots->valid() &&
$this->has_more_chunks()
)
if(!$this->event_snapshots->valid())
{
$this->fetch();
}
Expand Down

0 comments on commit 816dfd0

Please sign in to comment.