Skip to content

Conversation

nordfjord
Copy link
Contributor

No description provided.

@@ -128,3 +128,20 @@ module StreamName =
/// Throws <c>InvalidArgumentException</c> if the stream name is not well-formed</summary>
/// <remarks>Inverse of <c>create</c></remarks>
let (|CategoryAndIds|) : StreamName -> struct (string * string[]) = splitCategoryAndIds

module Parse =
let parse category f (name: StreamName) =
Copy link
Collaborator

@bartelink bartelink Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line, inside module and at EOF
but module can be skipped - Internal was to hide low usage stuff esp with names that sort all over the completion list
can you do a 4th one too - streamId ones have 4
also why no pattern match to pull the ids out of the array and validate len ? (can use CategoryAndIds pattern)

| _ -> failwith "Unexpected match"


let [<Fact>] ``It works with Guid's`` () =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no ' in Guids (or id's!) ;)

/// Represents the second half of a canonical StreamName, i.e., the streamId in "{categoryName}-{streamId}"
type StreamId = string<streamId>
and [<Measure>] streamId
/// Low-level helpers for composing and rendering StreamId values; prefer the ones in the Equinox namespace
Copy link
Collaborator

@bartelink bartelink Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these guys belong in a module Internal
(want real short completion list, only Equinox Stores should need these, and ideally they should inline most of them unless there is a reason to believe someone outside should be using them)

/// Render as a canonical "{categoryName}-{streamId}" StreamName. Throws if the categoryName embeds `-` chars.
let renderStreamName categoryName (x: StreamId): StreamName = toString x |> StreamName.create categoryName

/// Generate a StreamId from a single application-level id, given a rendering function that maps to a non empty fragment without embedded `_` chars
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont forget to bring back the type - these are ugly to all from C# (and there is a sample that uses it)

@@ -0,0 +1,37 @@
namespace FsCodec
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module FsCodec.StreamId?

then ValueSome struct(f ids[0], g ids[1], h ids[2])
else ValueNone
/// Extracts the application-level id of a StreamName
let dec category f (name: StreamName) = function
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should split the streamId and throw if >1 item

@bartelink bartelink mentioned this pull request Aug 4, 2023
@nordfjord
Copy link
Contributor Author

Superseded by #100

@nordfjord nordfjord closed this Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants