Skip to content

Commit f147ee1

Browse files
author
Jamil Maqdis Anton
committed
WIP
1 parent 03ac9c0 commit f147ee1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Read.fs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
open System.Threading
44
open SqlStreamStore
55
open SqlStreamStore.Streams
6+
open Insurello.AsyncExtra
67

78
type ReadingDirection =
89
| Forward
@@ -34,3 +35,17 @@ module ReadExtras =
3435
if messageList.Length = msgCount
3536
then Ok messageList
3637
else Error(sprintf "Failed to retrieve all messages. Messages retrieved count: %d" messageList.Length)
38+
39+
let readStreamMessages': IStreamStore -> ReadingDirection -> StreamDetails -> int -> AsyncResult<List<StreamMessage>, string> =
40+
fun store direction stream msgCount ->
41+
Read.readFromStreamAsync store direction stream msgCount
42+
|> Async.bind (fun readStreamPage ->
43+
readStreamPage.Messages
44+
|> Seq.toList
45+
|> fun messageList ->
46+
if messageList.Length = msgCount then
47+
Ok messageList
48+
else
49+
Error
50+
(sprintf "Failed to retrieve all messages. Messages retrieved count: %d" messageList.Length)
51+
|> AsyncResult.fromResult)

src/SqlStreamStore.FSharp.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15+
<PackageReference Include="Insurello.AsyncExtra" Version="1.1.0" />
1516
<PackageReference Include="SqlStreamStore" Version="1.2.0-beta.8" />
1617
<PackageReference Include="SqlStreamStore.Postgres" Version="1.2.0-beta.8" />
1718
</ItemGroup>

0 commit comments

Comments
 (0)