Skip to content

Commit

Permalink
Add module Stream private mention
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Sep 11, 2023
1 parent 06edb58 commit 2eeab15
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,44 @@ Some notes about the intents being satisfied here:
sibling code in adjacent `module`s should not be using them directly (in
general interaction should be via the `type Service`)

✅ DO keep `module Stream` visibility `private`, present via `module Reactions`

If the composition of stream names is relevant for Reactions processing, expose relevant helpers in a `module Reactions` facade.
For instance, rather than having external reaction logic refer to `Aggregate.Stream.Category`, expose a facade such as:

```fsharp
module Reactions =
let streamName = Stream.name
let deletionNamePrefix tenantIdStr = $"%s{Stream.Category}-%s{tenantIdStr}"
```

✅ DO use tupled arguments for the `Stream.id` function

All the inputs of which the `StreamId` is composed should be represented as one argument:

```fsharp
✅ let id struct (tenantId, clientId) = FsCodec.StreamId.gen2 TenantId.toString ClientId.toString (tenantId, clientId)
✅ let id = FsCodec.StreamId.gen2 TenantId.toString ClientId.toString
❌ let id tenantId clientId = FsCodec.StreamId.gen2 TenantId.toString ClientId.toString (tenantId, clientId)
```

✅ DO keep `module Stream` visibility `private`, present via `module Reactions`

If the composition of stream names is relevant for Reactions processing, expose relevant helpers in a `module Reactions` facade.
For instance, rather than having external reaction logic refer to `Aggregate.Stream.Category`, expose a facade such as:

```fsharp
module Reactions =
let streamName = Stream.name
let deletionNamePrefix tenantIdStr = $"%s{Stream.Category}-%s{tenantIdStr}"
let [<return: Struct>] (|For|_|) = Stream.tryDecode
let [<return: Struct>] (|Decode|_|) = function
| struct (For id, _) & Streams.Decode dec events -> ValueSome struct (id, events)
| _ -> ValueNone
```

```fsharp
module Fold =
Expand Down

0 comments on commit 2eeab15

Please sign in to comment.