Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Jul 13, 2024
1 parent 8770230 commit 06876c7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Propulsion.CosmosStore/CosmosStoreSink.fs
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@ module Internal =
let! res = ctx.Sync(stream, { index = i; etag = None }, span |> Array.map (fun x -> StreamSpan.defaultToNative_ x :> _))
|> Async.executeAsTask ct
#else
let unfolds, span = span |> Array.partition _.IsUnfold
let unfolds, events = span |> Array.partition _.IsUnfold
let mkUnfold baseIndex (compressor, x: IEventData<'t>): Unfold =
{ i = baseIndex; t = x.Timestamp
c = x.EventType; d = compressor x.Data; m = compressor x.Meta }
let mapData = FsCodec.Core.EventData.Map StreamSpan.toNativeEventBody
let unfolds = unfolds |> Array.map (fun x -> (*Equinox.CosmosStore.Core.Store.Sync.*)mkUnfold i (StreamSpan.toNativeEventBody, x))
let! res = ctx.Sync(stream, { index = i; etag = None }, span |> Array.map mapData, unfolds, ct)
let! res = ctx.Sync(stream, { index = i; etag = None }, events |> Array.map mapData, unfolds, ct)
#endif
let res' =
match res with
| AppendResult.Ok pos -> Result.Ok pos.index
| AppendResult.Conflict (pos, _) | AppendResult.ConflictUnknown pos ->
// TODO can't drop unfolds
match pos.index with
| actual when actual < i -> Result.PrefixMissing (span, actual) // TODO
| actual when actual < i -> Result.PrefixMissing (span, actual) // TODO ensure unfolds are merged with potential fresh ones correctly
| actual when actual >= n -> Result.Duplicate actual
| actual -> Result.PartialDuplicate (span |> Array.skip (actual - i |> int)) // TODO
| actual -> Result.PartialDuplicate (span |> Array.skip (actual - i |> int)) // TODO ensure unfolds are merged correctly
log.Debug("Result: {res}", res')
return res' }
let containsMalformedMessage e =
Expand Down

0 comments on commit 06876c7

Please sign in to comment.