Closed burzum closed 3 years ago
Ah the package is now using simple callbacks instead of new class() implements ... { public function __invoke(
. We just forgot to update the examples.
@enumag correct, I've already changed this but I'm getting into the other issues I've mentioned above after that. Some typed properties are not initialized. This has been easy to fix as well in the package. But I'm stuck at
Fatal error: Uncaught Error: Interface 'Prooph\EventStore\EventAppearedOnSubscription' not found in \vendor\prooph\event-store-http-client\src\Internal\EventStoreCatchUpSubscription.php:167
I might spend a little more time on this later.
These changes seem to make it work:
diff --git "a/src/Internal/EventStoreCatchUpSubscription.php" "b/src/Internal/EventStoreCatchUpSubscription.php"
index 2e61263..c29020d 100644
--- "a/src/Internal/EventStoreCatchUpSubscription.php"
+++ "b/src/Internal/EventStoreCatchUpSubscription.php"
@@ -55,9 +55,9 @@ abstract class EventStoreCatchUpSubscription implements SyncEventStoreCatchUpSub
private ?DropData $dropData;
private bool $allowProcessing;
private bool $isProcessing;
- protected bool $shouldStop;
- private bool $isDropped;
- private bool $stopped;
+ protected bool $shouldStop = false;
+ private bool $isDropped = false;
+ private bool $stopped = false;
/**
* @internal
@@ -93,6 +93,7 @@ abstract class EventStoreCatchUpSubscription implements SyncEventStoreCatchUpSub
$this->liveQueue = new SplQueue();
$this->subscriptionName = $settings->subscriptionName() ?? '';
$this->stopped = true;
+ $this->subscription = null;
}
public function isSubscribedToAll(): bool
@@ -163,37 +164,19 @@ abstract class EventStoreCatchUpSubscription implements SyncEventStoreCatchUpSub
private function subscribeToStream(): void
{
if (! $this->shouldStop) {
- $eventAppeared = new class(Closure::fromCallable([$this, 'enqueuePushedEvent'])) implements EventAppearedOnSubscription {
- private $callback;
-
- public function __construct(callable $callback)
- {
- $this->callback = $callback;
- }
-
- public function __invoke(
+ $eventAppeared = function(
EventStoreSubscription $subscription,
ResolvedEvent $resolvedEvent
): void {
($this->callback)($subscription, $resolvedEvent);
- }
- };
+ };
- $subscriptionDropped = new class(Closure::fromCallable([$this, 'serverSubscriptionDropped'])) implements SubscriptionDropped {
- private $callback;
-
- public function __construct(callable $callback)
- {
- $this->callback = $callback;
- }
-
- public function __invoke(
+ $subscriptionDropped = function(
EventStoreSubscription $subscription,
SubscriptionDropReason $reason,
?Throwable $exception = null
): void {
($this->callback)($reason, $exception);
- }
};
$subscription = empty($this->streamId)
@burzum Looks good so far.
https://github.com/prooph/event-store-http-client/blob/master/examples/demo-subscribe-to-stream-from.php
When I fix these, I'm getting a lot of these
which are easy to fix. I've got stuck at this point:
I'm not sure what I need to change here to make it work again.