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

Add eqx dump cosmos #177

Merged
merged 12 commits into from
Nov 8, 2019
Prev Previous commit
Next Next commit
Remove redundant tryDecode invocations for Unfolds
  • Loading branch information
bartelink committed Nov 7, 2019
commit 8eb867a14cd4be0e327dad91146535801053b96c
13 changes: 10 additions & 3 deletions src/Equinox.Cosmos/Cosmos.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Equinox.Cosmos.Store
namespace Equinox.Cosmos.Store

open Equinox.Core
open FsCodec
Expand Down Expand Up @@ -809,9 +809,16 @@ type BatchingPolicy

type Gateway(conn : Connection, batching : BatchingPolicy) =
let (|FromUnfold|_|) (tryDecode: #IEventData<_> -> 'event option) (isOrigin: 'event -> bool) (xs:#IEventData<_>[]) : Option<'event[]> =
match Array.tryFindIndexBack (tryDecode >> Option.exists isOrigin) xs with
let items = ResizeArray()
let isOrigin' e =
match tryDecode e with
| None -> false
| Some e ->
items.Insert(0,e)
isOrigin e
match Array.tryFindIndexBack isOrigin' xs with
| None -> None
| Some index -> xs |> Seq.skip index |> Seq.choose tryDecode |> Array.ofSeq |> Some
| Some _ -> items.ToArray() |> Some
member __.Client = conn.Client
member __.LoadBackwardsStopping log (container, stream) (tryDecode,isOrigin): Async<StreamToken * 'event[]> = async {
let! pos, events = Query.walk log (container,stream) conn.QueryRetryPolicy batching.MaxItems batching.MaxRequests Direction.Backward None (tryDecode,isOrigin)
Expand Down