Skip to content

Commit

Permalink
TASK: Remove SubscriptionManager and make subscriptions immutable
Browse files Browse the repository at this point in the history
This removes any magic from the code flow and makes transactions, locking, and update more explicit and easier to follow.
  • Loading branch information
mhsdesign committed Nov 27, 2024
1 parent 553c788 commit be0f545
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Classes/Factory/SubscriptionStore/DoctrineSubscriptionStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setup(): void
}
}

public function findByCriteria(SubscriptionCriteria $criteria): Subscriptions
public function findByCriteriaForUpdate(SubscriptionCriteria $criteria): Subscriptions
{
$queryBuilder = $this->dbal->createQueryBuilder()
->select('*')
Expand Down Expand Up @@ -107,15 +107,24 @@ public function add(Subscription $subscription): void
);
}

public function update(Subscription $subscription): void
{
$row = self::toDatabase($subscription);
public function update(
SubscriptionId $subscriptionId,
SubscriptionStatus $status,
SequenceNumber $position,
SubscriptionError|null $subscriptionError,
): void {
$row = [];
$row['last_saved_at'] = $this->clock->now()->format('Y-m-d H:i:s');
$row['status'] = $status->name;
$row['position'] = $position->value;
$row['error_message'] = $subscriptionError?->errorMessage;
$row['error_previous_status'] = $subscriptionError?->previousStatus?->name;
$row['error_trace'] = $subscriptionError?->errorTrace;
$this->dbal->update(
$this->tableName,
$row,
[
'id' => $subscription->id->value,
'id' => $subscriptionId->value,
]
);
}
Expand Down

0 comments on commit be0f545

Please sign in to comment.