Skip to content
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

refactor(MemoryStore)!: remove unused TrySync args #466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The `Unreleased` section name is replaced by the expected version of next releas
- `Equinox.*Store`,`Equinox.*Store.Prometheus`: Pin `Equinox` dependencies to `[4.0.0, 5.0.0)`] [#448](https://github.com/jet/equinox/pull/448)
- `Equinox.CosmosStore`: Update `System.Text.Json` dep to `6.0.10` per [CVE-2024-43485](https://github.com/advisories/GHSA-8g4q-xg66-9fp4) [#470](https://github.com/jet/equinox/pull/470)
- `Equinox.MessageDb`: Up min `Npgsql` to v `7.0.7` as `7.0.0` is on CVE blacklist
- `Equinox.MemoryStore`: Remove unused TrySync args [#466](https://github.com/jet/equinox/pull/466)

### Removed

Expand Down
6 changes: 4 additions & 2 deletions src/Equinox.MemoryStore/MemoryStore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type VolatileStore<'Format>() =
events

/// Attempts a synchronization operation - yields conflicting value if expectedCount does not match
member _.TrySync(streamName, _categoryName, _streamId, expectedCount, events): struct (bool * FsCodec.ITimelineEvent<'Format>[]) =
member _.TrySync(streamName, expectedCount, events): struct (bool * FsCodec.ITimelineEvent<'Format>[]) =
// Where attempts overlap on the same stream, there's a race to raise the Committed event for each 'commit'
// If we don't serialize the publishing of the events, its possible for handlers to observe the Events out of order
// NOTE while a Channels based impl might offer better throughput at load, in practical terms serializing all Committed event notifications
Expand All @@ -47,6 +47,8 @@ type VolatileStore<'Format>() =
let struct (succeeded, _) as outcome = trySync streamName expectedCount events
if succeeded then committed.Trigger(FsCodec.StreamName.Internal.trust streamName, events)
outcome
[<System.Obsolete "Will be removed in v5">]
member x.TrySync(streamName, _categoryName, _streamId, expectedCount, events): struct (bool * FsCodec.ITimelineEvent<'Format>[]) = x.TrySync(streamName, expectedCount, events)

type private StoreCategory<'event, 'state, 'req, 'Format>(store: VolatileStore<'Format>, codec, fold, initial) =
let fold s xs = (fold : System.Func<'state, 'event[], 'state>).Invoke(s, xs)
Expand All @@ -60,7 +62,7 @@ type private StoreCategory<'event, 'state, 'req, 'Format>(store: VolatileStore<'
| xs -> return res xs.Length initial (decode xs) }
member _.Sync(_log, categoryName, streamId, streamName, req, token, state, events, _ct) = task {
let encoded = events |> Array.mapi (fun i e -> FsCodec.Core.TimelineEvent.Create(token.version + int64 i, codec.Encode(req, e)))
match store.TrySync(streamName, categoryName, streamId, int token.version, encoded) with
match store.TrySync(streamName, int token.version, encoded) with
| true, streamEvents' ->
return SyncResult.Written (res streamEvents'.Length state events)
| false, conflictingEvents ->
Expand Down