Skip to content

Commit 7f509c6

Browse files
committed
Helper naming consistency
1 parent 87e62f4 commit 7f509c6

File tree

24 files changed

+96
-88
lines changed

24 files changed

+96
-88
lines changed

equinox-testbed/Infrastructure.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ module Guid =
1616
/// ClientId strongly typed id; represented internally as a Guid; not used for storage so rendering is not significant
1717
type ClientId = Guid<clientId>
1818
and [<Measure>] clientId
19-
module ClientId = let toStringN (value : ClientId) : string = Guid.toStringN %value
19+
module ClientId = let toString (value : ClientId) : string = Guid.toStringN %value
2020

2121
/// SkuId strongly typed id; represented internally as a Guid
2222
// NB Perf is suboptimal as a key, see Equinox's samples/Store for expanded version
2323
type SkuId = Guid<skuId>
2424
and [<Measure>] skuId
25-
module SkuId = let toStringN (value : SkuId) : string = Guid.toStringN %value
25+
module SkuId = let toString (value : SkuId) : string = Guid.toStringN %value

equinox-testbed/Services.fs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Domain =
77

88
// NB - these schemas reflect the actual storage formats and hence need to be versioned with care
99
module Events =
10+
1011
type Favorited = { date: System.DateTimeOffset; skuId: SkuId }
1112
type Unfavorited = { skuId: SkuId }
1213
module Compaction =
@@ -20,6 +21,7 @@ module Domain =
2021
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
2122

2223
module Folds =
24+
2325
type State = Events.Favorited []
2426

2527
type private InternalState(input: State) =
@@ -61,7 +63,8 @@ module Domain =
6163
[ Events.Unfavorited { skuId = skuId } ]
6264

6365
type Service(log, resolveStream, ?maxAttempts) =
64-
let (|AggregateId|) (id: ClientId) = Equinox.AggregateId("Favorites", ClientId.toStringN id)
66+
67+
let (|AggregateId|) (id: ClientId) = Equinox.AggregateId("Favorites", ClientId.toString id)
6568
let (|Stream|) (AggregateId id) = Equinox.Stream(log, resolveStream id, defaultArg maxAttempts 2)
6669
let execute (Stream stream) command : Async<unit> =
6770
stream.Transact(Commands.interpret command)

equinox-web/Domain/Aggregate.fs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
// NB - these types and names reflect the actual storage formats and hence need to be versioned with care
44
module Events =
5-
type Compacted = { happened: bool }
5+
6+
type CompactedData = { happened: bool }
67

78
type Event =
89
| Happened
9-
| Compacted of Compacted
10+
| Compacted of CompactedData
1011
interface TypeShape.UnionContract.IUnionContract
11-
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
12+
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>(rejectNullaryCases=false)
1213

1314
module Folds =
1415

@@ -33,6 +34,7 @@ module Commands =
3334
type View = { sorted : bool }
3435

3536
type Service(handlerLog, resolve, ?maxAttempts) =
37+
3638
let (|AggregateId|) (id: string) = Equinox.AggregateId("Aggregate", id)
3739
let (|Stream|) (AggregateId id) = Equinox.Stream(handlerLog, resolve id, maxAttempts = defaultArg maxAttempts 2)
3840

equinox-web/Domain/Infrastructure.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ module Guid =
1010
type ClientId = Guid<clientId>
1111
and [<Measure>] clientId
1212
module ClientId =
13-
let toStringN (value : ClientId) : string = Guid.toStringN %value
13+
let toString (value : ClientId) : string = Guid.toStringN %value

equinox-web/Domain/Todo.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ type View = { id: int; order: int; title: string; completed: bool }
7272

7373
/// Defines operations that a Controller can perform on a Todo List
7474
type Service(handlerLog, resolve, ?maxAttempts) =
75+
7576
/// Maps a ClientId to the AggregateId that specifies the Stream in which the data for that client will be held
76-
let (|AggregateId|) (clientId: ClientId) = Equinox.AggregateId("Todos", ClientId.toStringN clientId)
77+
let (|AggregateId|) (clientId: ClientId) = Equinox.AggregateId("Todos", ClientId.toString clientId)
7778

7879
/// Maps a ClientId to Handler for the relevant stream
7980
let (|Stream|) (AggregateId id) = Equinox.Stream(handlerLog, resolve id, maxAttempts = defaultArg maxAttempts 2)

propulsion-consumer/Examples.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module MultiStreams =
5757
interface TypeShape.UnionContract.IUnionContract
5858
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
5959
let tryDecode = StreamCodec.tryDecode codec
60-
let [<Literal>] CategoryId = "SavedForLater"
60+
let [<Literal>] categoryId = "SavedForLater"
6161

6262
// NB - these schemas reflect the actual storage formats and hence need to be versioned with care
6363
module Favorites =
@@ -70,7 +70,7 @@ module MultiStreams =
7070
interface TypeShape.UnionContract.IUnionContract
7171
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
7272
let tryDecode = StreamCodec.tryDecode codec
73-
let [<Literal>] CategoryId = "Favorites"
73+
let [<Literal>] categoryId = "Favorites"
7474

7575
type Stat = Faves of int | Saves of int | OtherCategory of string * int | OtherMessage of string
7676

@@ -85,10 +85,10 @@ module MultiStreams =
8585
let (|FavoritesEvents|SavedForLaterEvents|OtherCategory|UnknownMessage|) (streamName, span : Propulsion.Streams.StreamSpan<byte[]>) =
8686
let decode tryDecode = span.events |> Seq.choose (tryDecode log streamName) |> Array.ofSeq
8787
match category streamName with
88-
| Category (Favorites.CategoryId, id) ->
88+
| Category (Favorites.categoryId, id) ->
8989
let s = match faves.TryGetValue id with true, value -> value | false, _ -> new HashSet<SkuId>()
9090
FavoritesEvents (id, s, decode Favorites.tryDecode)
91-
| Category (SavedForLater.CategoryId, id) ->
91+
| Category (SavedForLater.categoryId, id) ->
9292
let s = match saves.TryGetValue id with true, value -> value | false, _ -> []
9393
SavedForLaterEvents (id, s, decode SavedForLater.tryDecode)
9494
| Category (categoryName, _) -> OtherCategory (categoryName, Seq.length span.events)
@@ -185,8 +185,8 @@ module MultiMessages =
185185
let span = Propulsion.Codec.NewtonsoftJson.RenderedSpan.Parse spanJson
186186
let decode tryDecode wrap = RenderedSpan.enum span |> Seq.choose (fun x -> x.event |> tryDecode log streamName |> Option.map wrap)
187187
match streamName with
188-
| Category (Favorites.CategoryId,_) -> yield! decode Favorites.tryDecode Fave
189-
| Category (SavedForLater.CategoryId,_) -> yield! decode SavedForLater.tryDecode Save
188+
| Category (Favorites.categoryId,_) -> yield! decode Favorites.tryDecode Fave
189+
| Category (SavedForLater.categoryId,_) -> yield! decode SavedForLater.tryDecode Save
190190
| Category (otherCategoryName,_) -> yield OtherCat (otherCategoryName, Seq.length span.e)
191191
| _ -> yield Unclassified streamName }
192192

propulsion-consumer/Program.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ let start (args : CmdParser.Arguments) =
7373

7474
/// Handles command line parsing and running the program loop
7575
// NOTE Any custom logic should go in main
76-
let run argv =
77-
try use consumer = argv |> CmdParser.parse |> start
76+
let run args =
77+
try use consumer = args |> CmdParser.parse |> start
7878
consumer.AwaitCompletion() |> Async.RunSynchronously
7979
if consumer.RanToCompletion then 0 else 2
8080
with :? Argu.ArguParseException as e -> eprintfn "%s" e.Message; 1

propulsion-consumer/Publisher.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module Input =
3636

3737
let codec = FsCodec.NewtonsoftJson.Codec.Create<Event>()
3838
let tryDecode = StreamCodec.tryDecode codec
39-
let [<Literal>] CategoryId = "Inventory"
39+
let [<Literal>] categoryId = "Inventory"
4040

4141
module Output =
4242

@@ -113,7 +113,7 @@ module Processor =
113113

114114
let private enumStreamEvents(KeyValue (streamName : string, spanJson)) : seq<Propulsion.Streams.StreamEvent<_>> =
115115
match streamName with
116-
| Category (Input.CategoryId,_) -> Propulsion.Codec.NewtonsoftJson.RenderedSpan.parse spanJson
116+
| Category (Input.categoryId,_) -> Propulsion.Codec.NewtonsoftJson.RenderedSpan.parse spanJson
117117
| _ -> Seq.empty
118118

119119
let log = Log.ForContext<Handler>()

propulsion-projector/Program.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ let build (args : CmdParser.Arguments) =
213213

214214
/// Handles command line parsing and running the program loop
215215
// NOTE Any custom logic should go in main
216-
let run argv =
217-
try let sink,runSourcePipeline = argv |> CmdParser.parse |> build
216+
let run args =
217+
try let sink,runSourcePipeline = args |> CmdParser.parse |> build
218218
runSourcePipeline |> Async.Start
219219
sink.AwaitCompletion() |> Async.RunSynchronously
220220
if sink.RanToCompletion then 0 else 2

propulsion-summary-consumer/Infrastructure.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ module Guid =
3232
type ClientId = Guid<clientId>
3333
and [<Measure>] clientId
3434
module ClientId =
35-
let toStringN (value : ClientId) : string = Guid.toStringN %value
35+
let toString (value : ClientId) : string = Guid.toStringN %value
3636
let parse (value : string) : ClientId = let raw = Guid.Parse value in % raw

0 commit comments

Comments
 (0)