Skip to content

Commit e92c192

Browse files
author
Jamil Maqdis Anton
committed
Add read and prefetch functions
1 parent d2c042b commit e92c192

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

src/Read.fs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,20 @@ module Read =
1919
: Async<Result<ReadStreamPage, string>> =
2020
ReadRaw.readFromStream store readingDirection streamName readVersion msgCount
2121
|> ExceptionsHandler.simpleExceptionHandler
22+
23+
let readFromAllStreamAndPrefetchJsonData (store: SqlStreamStore.IStreamStore)
24+
(readingDirection: ReadingDirection)
25+
(startPositionInclusive: StartPosition)
26+
(msgCount: int)
27+
: Async<Result<ReadAllPage, string>> =
28+
ReadRaw.readFromAllStream' store readingDirection startPositionInclusive msgCount true
29+
|> ExceptionsHandler.simpleExceptionHandler
30+
31+
let readFromStreamAndPrefetchJsonData (store: SqlStreamStore.IStreamStore)
32+
(readingDirection: ReadingDirection)
33+
(streamName: string)
34+
(readVersion: ReadVersion)
35+
(msgCount: int)
36+
: Async<Result<ReadStreamPage, string>> =
37+
ReadRaw.readFromStream' store readingDirection streamName readVersion msgCount true
38+
|> ExceptionsHandler.simpleExceptionHandler

src/ReadRaw.fs

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,12 @@ module ReadRaw =
4545
(startPositionInclusive: StartPosition)
4646
(msgCount: int)
4747
(prefetchJson: bool)
48-
(cancellationToken: CancellationToken)
4948
: Async<ReadAllPage> =
5049
match readingDirection with
5150
| ReadingDirection.Forward ->
52-
store.ReadAllForwards
53-
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
51+
store.ReadAllForwards(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson)
5452
| ReadingDirection.Backward ->
55-
store.ReadAllBackwards
56-
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
53+
store.ReadAllBackwards(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson)
5754
|> Async.AwaitTask
5855

5956
let readFromStream' (store: SqlStreamStore.IStreamStore)
@@ -62,9 +59,39 @@ module ReadRaw =
6259
(readVersion: ReadVersion)
6360
(msgCount: int)
6461
(prefetchJson: bool)
65-
(cancellationToken: CancellationToken)
6662
: Async<ReadStreamPage> =
6763
match readingDirection with
64+
| ReadingDirection.Forward ->
65+
store.ReadStreamForwards(StreamId(streamName), fromReadVersion readVersion, msgCount, prefetchJson)
66+
| ReadingDirection.Backward ->
67+
store.ReadStreamBackwards(StreamId(streamName), fromReadVersion readVersion, msgCount, prefetchJson)
68+
|> Async.AwaitTask
69+
70+
let readFromAllStream'' (store: SqlStreamStore.IStreamStore)
71+
(readingDirection: ReadingDirection)
72+
(startPositionInclusive: StartPosition)
73+
(msgCount: int)
74+
(prefetchJson: bool)
75+
(cancellationToken: CancellationToken)
76+
: Async<ReadAllPage> =
77+
match readingDirection with
78+
| ReadingDirection.Forward ->
79+
store.ReadAllForwards
80+
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
81+
| ReadingDirection.Backward ->
82+
store.ReadAllBackwards
83+
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
84+
|> Async.AwaitTask
85+
86+
let readFromStream'' (store: SqlStreamStore.IStreamStore)
87+
(readingDirection: ReadingDirection)
88+
(streamName: string)
89+
(readVersion: ReadVersion)
90+
(msgCount: int)
91+
(prefetchJson: bool)
92+
(cancellationToken: CancellationToken)
93+
: Async<ReadStreamPage> =
94+
match readingDirection with
6895
| ReadingDirection.Forward ->
6996
store.ReadStreamForwards
7097
(StreamId(streamName), fromReadVersion readVersion, msgCount, prefetchJson, cancellationToken)

0 commit comments

Comments
 (0)