Repository navigation
Release v19.150.0
Projections can now express read models that previously needed a reducer: dictionary entries keyed by event content, removing a dictionary key, set once, and ordered children (part of #5755).
Added
- A dictionary entry in a projection can be keyed by a property of the event's content, for example
slots.$eventContent.slot, alongside the existing event context and caused by keys. Set, set once, add, subtract, increment, decrement and count all accept such a key. An event whose key is missing or null skips the mapping, and a key path the event type does not have fails when the projection is registered (#5756) - A dictionary key can be removed with the
$removeoperation, and every sink (MongoDB, SQL and in-memory) removes the entry instead of leaving it as null. Removing a key that does not exist does nothing (#5756) - Set once assigns a property only when it has no value yet, on the root, on children, on nested objects and on dictionary entries, so a read model can keep who created an entry and when (#5757)
- Children can be ordered: new children can be prepended or kept sorted by a child property, ascending or descending. Equal values are ordered by the child's identifier, and MongoDB, SQL, in-memory and the projection engine all store the same order. Appending stays the default, and updating an existing child never moves it (#5758)
- The .NET client supports these operations in fluent projections (
SetOnce,RemoveKey, dictionary keys from event content and children ordering) and in model-bound projections through theSetFrom,SetFromContextandChildrenFromattributes. They are also supported byReadModelScenarioand recognized by the projection analyzers (#5759)
Changed
- A projection whose children ordering is invalid now fails when it is registered: an unknown placement or direction, a sorted ordering without a sort property, or a sort property that is missing on the child or is an object or a collection
- A dictionary key read from event content cannot contain
.,[,]or a null character, and cannot be empty or start with$. An event that produces such a key fails its partition, which shows in the Workbench, instead of writing to the wrong place - Dictionary keys and child sort values are formatted and compared the same way on every server, independent of its culture
- A plain set into a dictionary entry with a dynamic key now stores the dictionary's declared value type, for example a 32-bit integer for
Dictionary<string, int>, instead of always a 64-bit integer. Counting and arithmetic on dictionary entries still use 64-bit integers
Fixed
- A replay that cannot begin now says why. The job's failure reads
Could not begin observer replay: ProjectionNotFoundwhen the projection does not exist andCould not begin observer replay: Failedwhen establishing the replay threw, instead of the uninformativeUnknown(#5761) - Updating Cratis.Choreography to 2.3.1 finalizes a replay job that was stuck starting although every step had already finished, and drains the backlog of expired finished jobs in a single cleanup run instead of 100 per hour (#5762)