-
-
Notifications
You must be signed in to change notification settings - Fork 11
fix: Critical global position bug + Complete backward reading test coverage #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
43a6669
Rename positive to natural
NickSeagull f24016b
Improve types
NickSeagull 14f819f
Fix global stream ordering tests
NickSeagull 58bb3d8
Fix types
NickSeagull c168ad9
Remove natural from limit
NickSeagull 783e05b
Add missing INLINE pragmas
NickSeagull 5a36487
Fix more errors
NickSeagull 871f01e
Comment out GlobalStreamOrdering tests
NickSeagull a621221
WIP
NickSeagull 8e0388e
red: currently failing on same-position append for different entities
NickSeagull 05cb2da
WIP
NickSeagull 700015f
Modify in memory event store to use a composite key for streams
NickSeagull 31ab3c0
pass
NickSeagull 5f2deed
Removes TOML dependency
NickSeagull 3db3c9e
Enables individual stream ordering tests
NickSeagull 368009b
FAILING: Enables global stream ordering tests
NickSeagull 7924ded
Disables global stream ordering test
NickSeagull 3871cd1
Fix compilation
NickSeagull dd7cf08
Removes comment
NickSeagull b767008
red: failing test
NickSeagull d0291a3
fix test
NickSeagull 960295d
Reenable tests
NickSeagull 2a6f5e9
Re-enables optimistic concurrency tests
NickSeagull 68e281a
Increases initial event stream count
NickSeagull 010864b
Adds resumption to readAllEventsForwardFrom
NickSeagull 089219b
Adds backward event stream reading
NickSeagull f271edf
Adds maximum and minimum functions to Array
NickSeagull 0f2e466
Adds read all backwards from end
NickSeagull cfe8308
Adds read from arbitrary position test
NickSeagull d7dcd62
Adds filtered event stream reader
NickSeagull 8fa40a8
Adds event filtering by entity ID
NickSeagull bd59206
Adds filtered backward event reading
NickSeagull c8461c8
Simplifies test setup and assertions.
NickSeagull 2902be9
Fixes event global position assignment
NickSeagull bddc9d0
fix test
NickSeagull 5ad0042
Adds optimistic concurrency test
NickSeagull 4f3b525
Fixes backward stream reading position filtering
NickSeagull 46fb3b7
Adds backward stream reading test for end position
NickSeagull ea67edc
Removes unused import
NickSeagull 91bc314
Makes array maximum and minimum functions safe for empty arrays
NickSeagull ceb2cb1
Removes debug logging from stream event reading
NickSeagull b1648a8
style(test): remove unnecessary parentheses
NickSeagull 590125d
Removes outdated C# test references from test descriptions
NickSeagull ba59886
Refactors variable assignments for clarity
NickSeagull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,44 @@ | ||
| module Service.Event ( | ||
| Event (..), | ||
| InsertionEvent (..), | ||
| StreamId (..), | ||
| StreamPosition (..), | ||
| EntityId (..), | ||
| fromInsertionEvent, | ||
| ) where | ||
|
|
||
| import Core | ||
| import Service.Event.EntityId (EntityId (..)) | ||
| import Service.Event.StreamId (StreamId (..)) | ||
| import Service.Event.StreamPosition (StreamPosition (..)) | ||
|
|
||
|
|
||
| data Event = Event | ||
| { id :: Text, -- FIXME: Use Uuid | ||
| { id :: Uuid, | ||
| streamId :: StreamId, | ||
| position :: StreamPosition, -- Local position in stream | ||
|
|
||
| -- | Global position across all streams. Nothing when event is created | ||
| -- but not yet persisted to the global stream; Just when assigned a | ||
| -- position in the global event ordering. Used for global event queries | ||
| -- and maintaining causal ordering across different streams. | ||
| globalPosition :: Maybe StreamPosition | ||
| entityId :: EntityId, | ||
| localPosition :: StreamPosition, | ||
| globalPosition :: StreamPosition | ||
| } | ||
| deriving (Eq, Show, Ord, Generic) | ||
|
|
||
|
|
||
| newtype StreamId = StreamId Text | ||
| data InsertionEvent = InsertionEvent | ||
| { id :: Uuid, | ||
| streamId :: StreamId, | ||
| entityId :: EntityId, | ||
| localPosition :: StreamPosition | ||
| } | ||
| deriving (Eq, Show, Ord, Generic) | ||
|
|
||
|
|
||
| newtype StreamPosition = StreamPosition (Positive Int) | ||
| deriving (Eq, Show, Ord, Generic) | ||
| -- | Convert an insertion event to an event with a global position. | ||
| fromInsertionEvent :: StreamPosition -> InsertionEvent -> Event | ||
| fromInsertionEvent globalPosition event = | ||
| Event | ||
| { id = event.id, | ||
| streamId = event.streamId, | ||
| entityId = event.entityId, | ||
| localPosition = event.localPosition, | ||
| globalPosition | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| module Service.Event.EntityId ( | ||
| EntityId (..), | ||
| new, | ||
| ) where | ||
|
|
||
| import Core | ||
| import Task qualified | ||
| import Uuid qualified | ||
|
|
||
|
|
||
| newtype EntityId = EntityId Uuid | ||
| deriving (Eq, Show, Ord, Generic) | ||
|
|
||
|
|
||
| new :: Task _ EntityId | ||
| new = do | ||
| uuid <- Uuid.generate | ||
| EntityId uuid |> Task.yield | ||
|
NickSeagull marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.