Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Track updates, CategoryName #134

Merged
merged 14 commits into from
Nov 25, 2023
Merged

refactor: Track updates, CategoryName #134

merged 14 commits into from
Nov 25, 2023

Conversation

bartelink
Copy link
Collaborator

@bartelink bartelink commented Sep 3, 2023

@bartelink
Copy link
Collaborator Author

(comment at time pf first commit)

maybe sid.Gen should be called streamId and kept private in the CategoryId impl?

then sid can be called catId or cid ?

as for sid.Category, maybe that means going back to it being a top level Literal? But it was actually good that the default was that people cant just randomly refer to Aggregate.Category from anywhere across the galaxy

@bartelink
Copy link
Collaborator Author

bartelink commented Sep 3, 2023

Tried to apply here but it does not make things better

However in a closed source codebase where things are symmetric (i.e. all SNs get roundtripped in tests or reactors), this helper works well

type internal CategoryId<'ids>(name, gen: 'ids -> FsCodec.StreamId, dec: FsCodec.StreamId -> 'ids) =
    member _.StreamName = gen >> FsCodec.StreamName.create name
    member _.DecodeId = dec
    member _.TryDecode = FsCodec.StreamName.tryFind name >> ValueOption.map dec

it also forces instances to be internal, e.g.

let [<Literal>] private CategoryName = "invitationprocess"
let private catId = CategoryId(CategoryName, streamId, FsCodec.StreamId.dec2 TenantId.parse InvitationId.parse)

which is consumed by tests and reactions via:

module Reactions =

    let [<return: Struct>] (|For|_|) = catId.TryDecode

    let dec = Streams.Codec.dec<Events.Event>
    let config = catId.StreamName, dec
    let [<return: Struct>] (|Decode|_|) = function
        | struct (For id, _) & Streams.Decode dec events -> ValueSome struct (id, events)
        | _ -> ValueNone
    let deletionNamePrefix tenantIdStr = $"%s{CategoryName}-%s{tenantIdStr}"

So maybe module Stream goes away in the guidance to be replaced with that canonical helper?

@bartelink
Copy link
Collaborator Author

related jet/FsCodec#103

@bartelink bartelink changed the title CategoryId CategoryId, Sync updates Nov 25, 2023
@bartelink bartelink force-pushed the categoryid branch 2 times, most recently from da0ef79 to ccd6d32 Compare November 25, 2023 07:46
@bartelink bartelink changed the title CategoryId, Sync updates refactor: Track updates, CategoryName Nov 25, 2023
@bartelink bartelink marked this pull request as ready for review November 25, 2023 16:30
@bartelink
Copy link
Collaborator Author

bartelink commented Nov 25, 2023

@nordfjord I ended up putting CategoryId into the mix in e0ed634 for any place where there's a .dec being used, which works well IME...
Now I need to update the docs

@bartelink bartelink merged commit 6944217 into doc Nov 25, 2023
2 checks passed
@bartelink bartelink deleted the categoryid branch November 25, 2023 16:32
bartelink added a commit that referenced this pull request Nov 25, 2023
- CosmosStoreSource monitoring
- Handle various renames
@bartelink
Copy link
Collaborator Author

bartelink commented Nov 25, 2023

(thought this was merging to master 🤦 - ended up cherry-picking it to master in 482203a)

bartelink added a commit that referenced this pull request Nov 25, 2023
- CosmosStoreSource monitoring
- Handle various renames
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.

1 participant