Skip to content

Commit

Permalink
Re-split run, transact
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Feb 28, 2022
1 parent 821ee49 commit 7b47aef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Equinox/Decider.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ type Decider<'event, 'state>
let query maybeOption project = async {
let! tokenAndState = fetch maybeOption log
return project tokenAndState }
let transact maybeOption decide mapResult = async {
let! originTokenAndState = fetch maybeOption log
let run originTokenAndState decide mapResult =
let resyncRetryPolicy = defaultArg resyncPolicy (fun _log _attemptNumber resyncF -> async { return! resyncF })
let createDefaultAttemptsExhaustedException attempts : exn = MaxResyncsExhaustedException attempts :> exn
let createMaxAttemptsExhaustedException = defaultArg createAttemptsExhaustedException createDefaultAttemptsExhaustedException
Expand All @@ -44,7 +43,10 @@ type Decider<'event, 'state>
return raise (createMaxAttemptsExhaustedException attempt)
| Core.SyncResult.Written (token', streamState') ->
return mapResult result (token', streamState') }
return! loop originTokenAndState 1 }
loop originTokenAndState 1
let transact maybeOption decide mapResult = async {
let! originTokenAndState = fetch maybeOption log
return! run originTokenAndState decide mapResult }
let (|Context|) (token : Core.StreamToken, state) =
{ new ISyncContext<'state> with
member _.State = state
Expand Down

0 comments on commit 7b47aef

Please sign in to comment.