Skip to content

Commit

Permalink
TASK: Ensure status is serialized by value
Browse files Browse the repository at this point in the history
as we use SubscriptionStatus::from
  • Loading branch information
mhsdesign committed Dec 13, 2024
1 parent d53c361 commit 24890b9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private function setupSubscription(Subscription $subscription): ?Error
null
);
}
$this->logger?->debug(sprintf('Subscription Engine: Subscriber "%s" for "%s" has been setup, set to %s from previous %s.', $subscriber::class, $subscription->id->value, SubscriptionStatus::BOOTING->name, $subscription->status->name));
$this->logger?->debug(sprintf('Subscription Engine: Subscriber "%s" for "%s" has been setup, set to %s from previous %s.', $subscriber::class, $subscription->id->value, SubscriptionStatus::BOOTING->value, $subscription->status->name));
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@
*/
enum SubscriptionStatus : string
{
/**
* New subscribers e.g a newly installed package: will not be run on catchup active as it doesn't have its schema setup
*/
case NEW = 'NEW';
/**
* Subscriber was set up and can be catch-up via boot, but will not run on active
*/
case BOOTING = 'BOOTING';
/**
* Active subscribers will always be run if new events are commited
*/
case ACTIVE = 'ACTIVE';
/**
* Subscribers that are uninstalled will be detached and have to be reactivated
*/
case DETACHED = 'DETACHED';
/**
* Subscribers that are run into an error during catchup or setup
*/
case ERROR = 'ERROR';
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ public function update(
): void {
$row = [];
$row['last_saved_at'] = $this->clock->now()->format('Y-m-d H:i:s');
$row['status'] = $status->name;
$row['status'] = $status->value;
$row['position'] = $position->value;
$row['error_message'] = $subscriptionError?->errorMessage;
$row['error_previous_status'] = $subscriptionError?->previousStatus?->name;
$row['error_previous_status'] = $subscriptionError?->previousStatus?->value;
$row['error_trace'] = $subscriptionError?->errorTrace;
$this->dbal->update(
$this->tableName,
Expand All @@ -138,10 +138,10 @@ public function update(
private static function toDatabase(Subscription $subscription): array
{
return [
'status' => $subscription->status->name,
'status' => $subscription->status->value,
'position' => $subscription->position->value,
'error_message' => $subscription->error?->errorMessage,
'error_previous_status' => $subscription->error?->previousStatus?->name,
'error_previous_status' => $subscription->error?->previousStatus?->value,
'error_trace' => $subscription->error?->errorTrace,
];
}
Expand Down

0 comments on commit 24890b9

Please sign in to comment.