Skip to content

Commit

Permalink
TASK: Introduce "partial" flag on publish events
Browse files Browse the repository at this point in the history
This was done do ease debugging and still preserve the intention.
  • Loading branch information
mhsdesign committed Dec 10, 2024
1 parent 135dc67 commit 6bc3c55
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Feature: Discard individual nodes (basics)
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier-new" |
| previousContentStreamId | "user-cs-identifier" |
| partial | true |
When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "sir-david-nodenborough" to lead to node user-cs-identifier-new;sir-david-nodenborough;{}
Expand Down Expand Up @@ -172,6 +173,7 @@ Feature: Discard individual nodes (basics)
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier-new" |
| previousContentStreamId | "user-cs-identifier" |
| partial | false |
When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "sir-david-nodenborough" to lead to node user-cs-identifier-new;sir-david-nodenborough;{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,19 @@ Feature: Workspace based content publishing
When the command PublishWorkspace is executed with payload:
| Key | Value |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-new" |

Then I expect the content stream "user-cs-identifier" to not exist

Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-test"
And event at index 1 is of type "WorkspaceWasPublished" with payload:
| Key | Expected |
| sourceWorkspaceName | "user-test" |
| targetWorkspaceName | "live" |
| newSourceContentStreamId | "user-cs-new" |
| previousSourceContentStreamId | "user-cs-identifier" |
| partial | false |

When I am in workspace "live" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node cs-identifier;nody-mc-nodeface;{}
And I expect this node to have the following properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Feature: Individual node publication
| targetWorkspaceName | "live" |
| newSourceContentStreamId | "user-cs-identifier-remaining" |
| previousSourceContentStreamId | "user-cs-identifier" |
| partial | true |

And I am in workspace "live"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Feature: Publishing individual nodes (basics)
| targetWorkspaceName | "live" |
| newSourceContentStreamId | "user-cs-identifier-remaining" |
| previousSourceContentStreamId | "user-cs-identifier" |
| partial | false |
When I am in workspace "live" and dimension space point {}
Then I expect node aggregate identifier "sir-david-nodenborough" to lead to node cs-identifier;sir-david-nodenborough;{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Feature: Workspace discarding - basic functionality
| newContentStreamId | "user-cs-identifier-modified" |
Then I expect the content stream "user-cs-identifier" to not exist

Then I expect exactly 2 events to be published on stream with prefix "Workspace:user-test"
And event at index 1 is of type "WorkspaceWasDiscarded" with payload:
| Key | Expected |
| workspaceName | "user-test" |
| newContentStreamId | "user-cs-identifier-modified" |
| previousContentStreamId | "user-cs-identifier" |
| partial | false |

When I am in workspace "user-test" and dimension space point {}
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node user-cs-identifier-modified;nody-mc-nodeface;{}
And I expect this node to have the following properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ static function ($handle) use ($rebaseableCommands): void {
$baseWorkspace->workspaceName,
$command->newContentStreamId,
$workspace->currentContentStreamId,
partial: false
)
),
ExpectedVersion::ANY()
Expand Down Expand Up @@ -517,6 +518,7 @@ static function ($handle) use ($commandSimulator, $matchingCommands, $remainingC
$baseWorkspace->workspaceName,
$command->contentStreamIdForRemainingPart,
$workspace->currentContentStreamId,
partial: !$remainingCommands->isEmpty()
)
]),
ExpectedVersion::ANY()
Expand Down Expand Up @@ -622,6 +624,7 @@ static function ($handle) use ($commandsToKeep): void {
$command->workspaceName,
$command->newContentStreamId,
$workspace->currentContentStreamId,
partial: true
)
),
ExpectedVersion::ANY()
Expand Down Expand Up @@ -685,6 +688,7 @@ private function discardWorkspace(
$workspace->workspaceName,
$newContentStream,
$workspace->currentContentStreamId,
partial: false
)
),
ExpectedVersion::ANY()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public function __construct(
* The old content stream (which contains the discarded data)
*/
public ContentStreamId $previousContentStreamId,
/**
* Indicates if all events in the workspace have been discarded or if remaining changes are reapplied
*/
public bool $partial
) {
}

Expand All @@ -48,15 +52,12 @@ public static function fromArray(array $values): self
WorkspaceName::fromString($values['workspaceName']),
ContentStreamId::fromString($values['newContentStreamId']),
ContentStreamId::fromString($values['previousContentStreamId']),
$values['partial'] ?? false
);
}

public function jsonSerialize(): array
{
return [
'workspaceName' => $this->workspaceName,
'newContentStreamId' => $this->newContentStreamId,
'previousContentStreamId' => $this->previousContentStreamId,
];
return get_object_vars($this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static function fromArray(array $values): EventInterface
WorkspaceName::fromString($values['workspaceName']),
ContentStreamId::fromString($values['newContentStreamId']),
ContentStreamId::fromString($values['previousContentStreamId']),
partial: true
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static function fromArray(array $values): EventInterface
WorkspaceName::fromString($values['targetWorkspaceName']),
ContentStreamId::fromString($values['newSourceContentStreamId']),
ContentStreamId::fromString($values['previousSourceContentStreamId']),
partial: true
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ public function __construct(
/**
* The old content stream ID of $sourceWorkspaceName (which is not active anymore now)
*/
public ContentStreamId $previousSourceContentStreamId
public ContentStreamId $previousSourceContentStreamId,
/**
* Indicates if all events in the workspace have been published or if remaining changes are reapplied
*/
public bool $partial
) {
}

Expand All @@ -50,6 +54,7 @@ public static function fromArray(array $values): self
WorkspaceName::fromString($values['targetWorkspaceName']),
ContentStreamId::fromString($values['newSourceContentStreamId']),
ContentStreamId::fromString($values['previousSourceContentStreamId']),
$values['partial'] ?? false,
);
}

Expand Down

0 comments on commit 6bc3c55

Please sign in to comment.