Skip to content

Split reading direction into two options #15

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 1 commit into from
Apr 28, 2021
Merged
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
20 changes: 13 additions & 7 deletions src/Read.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ type ReadPartialOption =
| FromVersionInclusive of int
| MessageCount of int
| NoPrefetch
| ReadDirection of ReadDirection
| ReadForwards
| ReadBackWards

[<RequireQualifiedAccess>]
type ReadEntireOption =
| CancellationToken of CancellationToken
| FromVersionInclusive of int
| NoPrefetch
| ReadDirection of ReadDirection
| ReadForwards
| ReadBackWards

[<RequireQualifiedAccess>]
type ReadAllOption =
| CancellationToken of CancellationToken
| FromPositionInclusive of int64
| MessageCount of int
| NoPrefetch
| ReadDirection of ReadDirection
| ReadForwards
| ReadBackWards

module Read =

Expand All @@ -45,7 +48,8 @@ module Read =
| ReadPartialOption.FromVersionInclusive version -> fromVersionInclusive <- Some version
| ReadPartialOption.MessageCount count -> messageCount <- count
| ReadPartialOption.NoPrefetch -> prefetch <- false
| ReadPartialOption.ReadDirection direction -> readDirection <- direction)
| ReadPartialOption.ReadForwards -> readDirection <- ReadDirection.Forward
| ReadPartialOption.ReadBackWards -> readDirection <- ReadDirection.Backward)

let fromVersionInclusive' =
match readDirection, fromVersionInclusive with
Expand Down Expand Up @@ -90,12 +94,13 @@ module Read =
| ReadEntireOption.CancellationToken token -> cancellationToken <- token
| ReadEntireOption.FromVersionInclusive version -> fromVersionInclusive <- Some version
| ReadEntireOption.NoPrefetch -> prefetch <- false
| ReadEntireOption.ReadDirection direction -> readDirection <- direction)
| ReadEntireOption.ReadForwards -> readDirection <- ReadDirection.Forward
| ReadEntireOption.ReadBackWards -> readDirection <- ReadDirection.Backward)

let options =
[
ReadPartialOption.MessageCount System.Int32.MaxValue
ReadPartialOption.ReadDirection readDirection
ReadPartialOption.ReadForwards
]

let options' =
Expand Down Expand Up @@ -131,7 +136,8 @@ module Read =
| ReadAllOption.FromPositionInclusive position -> fromPositionInclusive <- Some position
| ReadAllOption.MessageCount count -> messageCount <- count
| ReadAllOption.NoPrefetch -> prefetch <- false
| ReadAllOption.ReadDirection direction -> readDirection <- direction)
| ReadAllOption.ReadForwards -> readDirection <- ReadDirection.Forward
| ReadAllOption.ReadBackWards -> readDirection <- ReadDirection.Backward)

let fromPositionInclusive' =
match readDirection, fromPositionInclusive with
Expand Down