Skip to content

Commit 2264ac8

Browse files
author
Jamil Maqdis Anton
committed
Remove unclear type aliases. Change function type annotation style
1 parent 64ac0ff commit 2264ac8

File tree

5 files changed

+84
-66
lines changed

5 files changed

+84
-66
lines changed

src/Append.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ open SqlStreamStore.Streams
44

55
module Append =
66
let appendNewMessage (store: SqlStreamStore.IStreamStore)
7-
(streamName: StreamName)
7+
(streamName: string)
88
(appendVersion: AppendVersion)
99
(messageDetails: MessageDetails)
1010
: Async<Result<AppendResult, string>> =
1111
AppendRaw.appendNewMessage store streamName appendVersion messageDetails
1212
|> ExceptionsHandler.simpleExceptionHandler
1313

1414
let appendNewMessages (store: SqlStreamStore.IStreamStore)
15-
(streamName: StreamName)
15+
(streamName: string)
1616
(appendVersion: AppendVersion)
1717
(messages: MessageDetails list)
1818
: Async<Result<AppendResult, string>> =

src/AppendRaw.fs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ module AppendRaw =
99
| StreamMessageId.Custom guid -> guid
1010
| StreamMessageId.Auto -> System.Guid.NewGuid()
1111

12-
let private newStreamMessageFromMessageDetails: MessageDetails -> NewStreamMessage =
13-
fun msg ->
14-
match msg.jsonMetadata with
15-
| "" -> NewStreamMessage(stringIdToGuid msg.id, msg.type_, msg.jsonData)
16-
| metadata -> NewStreamMessage(stringIdToGuid msg.id, msg.type_, msg.jsonData, metadata)
12+
let private newStreamMessageFromMessageDetails (msg: MessageDetails): NewStreamMessage =
13+
match msg.jsonMetadata with
14+
| "" -> NewStreamMessage(stringIdToGuid msg.id, msg.type_, msg.jsonData)
15+
| metadata -> NewStreamMessage(stringIdToGuid msg.id, msg.type_, msg.jsonData, metadata)
1716

1817
let private fromAppendVersion: AppendVersion -> int =
1918
function
@@ -22,20 +21,26 @@ module AppendRaw =
2221
| AppendVersion.NoStream -> ExpectedVersion.NoStream
2322
| AppendVersion.SpecificVersion version -> version
2423

25-
let appendNewMessage: SqlStreamStore.IStreamStore -> StreamName -> AppendVersion -> MessageDetails -> Async<AppendResult> =
26-
fun store streamName appendVersion messageDetails ->
27-
store.AppendToStream
28-
(StreamId(streamName),
29-
fromAppendVersion appendVersion,
30-
[| newStreamMessageFromMessageDetails messageDetails |])
31-
|> Async.AwaitTask
24+
let appendNewMessage (store: SqlStreamStore.IStreamStore)
25+
(streamName: string)
26+
(appendVersion: AppendVersion)
27+
(messageDetails: MessageDetails)
28+
: Async<AppendResult> =
29+
store.AppendToStream
30+
(StreamId(streamName),
31+
fromAppendVersion appendVersion,
32+
[| newStreamMessageFromMessageDetails messageDetails |])
33+
|> Async.AwaitTask
3234

33-
let appendNewMessages: SqlStreamStore.IStreamStore -> StreamName -> AppendVersion -> List<MessageDetails> -> Async<AppendResult> =
34-
fun store streamName appendVersion messages ->
35-
store.AppendToStream
36-
(StreamId(streamName),
37-
fromAppendVersion appendVersion,
38-
messages
39-
|> List.map newStreamMessageFromMessageDetails
40-
|> List.toArray)
41-
|> Async.AwaitTask
35+
let appendNewMessages (store: SqlStreamStore.IStreamStore)
36+
(streamName: string)
37+
(appendVersion: AppendVersion)
38+
(messages: MessageDetails list)
39+
: Async<AppendResult> =
40+
store.AppendToStream
41+
(StreamId(streamName),
42+
fromAppendVersion appendVersion,
43+
messages
44+
|> List.map newStreamMessageFromMessageDetails
45+
|> List.toArray)
46+
|> Async.AwaitTask

src/Read.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ module Read =
66
let readFromAllStream (store: SqlStreamStore.IStreamStore)
77
(readingDirection: ReadingDirection)
88
(startPositionInclusive: StartPosition)
9-
(msgCount: MessageCount)
9+
(msgCount: int)
1010
: Async<Result<ReadAllPage, string>> =
1111
ReadRaw.readFromAllStream store readingDirection startPositionInclusive msgCount
1212
|> ExceptionsHandler.simpleExceptionHandler
1313

1414
let readFromStream (store: SqlStreamStore.IStreamStore)
1515
(readingDirection: ReadingDirection)
16-
(streamName: StreamName)
16+
(streamName: string)
1717
(readVersion: ReadVersion)
18-
(msgCount: MessageCount)
18+
(msgCount: int)
1919
: Async<Result<ReadStreamPage, string>> =
2020
ReadRaw.readFromStream store readingDirection streamName readVersion msgCount
2121
|> ExceptionsHandler.simpleExceptionHandler

src/ReadRaw.fs

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,59 @@ module ReadRaw =
1616
| StartPosition.End -> -1L
1717
| StartPosition.SpecificPosition position -> position
1818

19-
let readFromAllStream: SqlStreamStore.IStreamStore -> ReadingDirection -> StartPosition -> MessageCount -> Async<ReadAllPage> =
20-
fun store readingDirection startPositionInclusive msgCount ->
21-
match readingDirection with
22-
| ReadingDirection.Forward ->
23-
store.ReadAllForwards(fromStartPositionInclusive startPositionInclusive, msgCount)
24-
| ReadingDirection.Backward ->
25-
store.ReadAllBackwards(fromStartPositionInclusive startPositionInclusive, msgCount)
26-
|> Async.AwaitTask
19+
let readFromAllStream (store: SqlStreamStore.IStreamStore)
20+
(readingDirection: ReadingDirection)
21+
(startPositionInclusive: StartPosition)
22+
(msgCount: int)
23+
: Async<ReadAllPage> =
24+
match readingDirection with
25+
| ReadingDirection.Forward -> store.ReadAllForwards(fromStartPositionInclusive startPositionInclusive, msgCount)
26+
| ReadingDirection.Backward ->
27+
store.ReadAllBackwards(fromStartPositionInclusive startPositionInclusive, msgCount)
28+
|> Async.AwaitTask
2729

28-
let readFromAllStream': SqlStreamStore.IStreamStore -> ReadingDirection -> StartPosition -> MessageCount -> bool -> CancellationToken -> Async<ReadAllPage> =
29-
fun store readingDirection startPositionInclusive msgCount prefetchJson cancellationToken ->
30-
match readingDirection with
31-
| ReadingDirection.Forward ->
32-
store.ReadAllForwards
33-
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
34-
| ReadingDirection.Backward ->
35-
store.ReadAllBackwards
36-
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
37-
|> Async.AwaitTask
30+
let readFromStream (store: SqlStreamStore.IStreamStore)
31+
(readingDirection: ReadingDirection)
32+
(streamName: string)
33+
(readVersion: ReadVersion)
34+
(msgCount: int)
35+
: Async<ReadStreamPage> =
36+
match readingDirection with
37+
| ReadingDirection.Forward ->
38+
store.ReadStreamForwards(StreamId(streamName), fromReadVersion readVersion, msgCount)
39+
| ReadingDirection.Backward ->
40+
store.ReadStreamBackwards(StreamId(streamName), fromReadVersion readVersion, msgCount)
41+
|> Async.AwaitTask
3842

39-
let readFromStream: SqlStreamStore.IStreamStore -> ReadingDirection -> StreamName -> ReadVersion -> MessageCount -> Async<ReadStreamPage> =
40-
fun store readingDirection streamName readVersion msgCount ->
41-
match readingDirection with
42-
| ReadingDirection.Forward ->
43-
store.ReadStreamForwards(StreamId(streamName), fromReadVersion readVersion, msgCount)
44-
| ReadingDirection.Backward ->
45-
store.ReadStreamBackwards(StreamId(streamName), fromReadVersion readVersion, msgCount)
46-
|> Async.AwaitTask
43+
let readFromAllStream' (store: SqlStreamStore.IStreamStore)
44+
(readingDirection: ReadingDirection)
45+
(startPositionInclusive: StartPosition)
46+
(msgCount: int)
47+
(prefetchJson: bool)
48+
(cancellationToken: CancellationToken)
49+
: Async<ReadAllPage> =
50+
match readingDirection with
51+
| ReadingDirection.Forward ->
52+
store.ReadAllForwards
53+
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
54+
| ReadingDirection.Backward ->
55+
store.ReadAllBackwards
56+
(fromStartPositionInclusive startPositionInclusive, msgCount, prefetchJson, cancellationToken)
57+
|> Async.AwaitTask
4758

48-
let readFromStream': SqlStreamStore.IStreamStore -> ReadingDirection -> StreamName -> ReadVersion -> MessageCount -> bool -> CancellationToken -> Async<ReadStreamPage> =
49-
fun store readingDirection streamName readVersion msgCount prefetchJson cancellationToken ->
50-
match readingDirection with
51-
| ReadingDirection.Forward ->
52-
store.ReadStreamForwards
53-
(StreamId(streamName), fromReadVersion readVersion, msgCount, prefetchJson, cancellationToken)
54-
| ReadingDirection.Backward ->
55-
store.ReadStreamBackwards
56-
(StreamId(streamName), fromReadVersion readVersion, msgCount, prefetchJson, cancellationToken)
57-
|> Async.AwaitTask
59+
let readFromStream' (store: SqlStreamStore.IStreamStore)
60+
(readingDirection: ReadingDirection)
61+
(streamName: string)
62+
(readVersion: ReadVersion)
63+
(msgCount: int)
64+
(prefetchJson: bool)
65+
(cancellationToken: CancellationToken)
66+
: Async<ReadStreamPage> =
67+
match readingDirection with
68+
| ReadingDirection.Forward ->
69+
store.ReadStreamForwards
70+
(StreamId(streamName), fromReadVersion readVersion, msgCount, prefetchJson, cancellationToken)
71+
| ReadingDirection.Backward ->
72+
store.ReadStreamBackwards
73+
(StreamId(streamName), fromReadVersion readVersion, msgCount, prefetchJson, cancellationToken)
74+
|> Async.AwaitTask

src/Types.fs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ type MessageDetails =
1111
jsonData: string
1212
jsonMetadata: string }
1313

14-
type StreamName = string
15-
1614
[<RequireQualifiedAccessAttribute>]
1715
type ReadVersion =
1816
| Start
@@ -32,8 +30,6 @@ type StartPosition =
3230
| End
3331
| SpecificPosition of int64
3432

35-
type MessageCount = int
36-
3733
[<RequireQualifiedAccessAttribute>]
3834
type ReadingDirection =
3935
| Forward

0 commit comments

Comments
 (0)