From 795c0351a383c912cfa0787eba3a4abc7aedadaa Mon Sep 17 00:00:00 2001 From: Pawel Trauth Date: Wed, 31 Jul 2019 17:39:01 +0100 Subject: [PATCH] fix: events duplication --- src/EventStoreWorker.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/EventStoreWorker.php b/src/EventStoreWorker.php index be15a12..aa07246 100644 --- a/src/EventStoreWorker.php +++ b/src/EventStoreWorker.php @@ -48,15 +48,16 @@ public function handle() public function processAllStreams() { - $eventStore = new EventStore(); - $connection = $eventStore->connect(config('eventstore.tcp_url')); $streams = config('eventstore.streams'); - $connection->subscribe(function () use ($eventStore, $streams) { - foreach ($streams as $stream) { + foreach ($streams as $stream) { + $eventStore = new EventStore(); + $connection = $eventStore->connect(config('eventstore.tcp_url')); + + $connection->subscribe(function () use ($eventStore, $stream) { $this->processStream($eventStore, $stream); - } - }, 'report'); + }, 'report'); + } } private function processStream($eventStore, string $stream)