Skip to content

Commit

Permalink
trace to owner
Browse files Browse the repository at this point in the history
  • Loading branch information
junkdog committed Nov 20, 2023
1 parent 654e5af commit 89171c0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

### New/Tweaks
- DSL: `filter(Enitity.Type, invert)` filters entities by type, now has an `invert` parameter.
- Faster template processing by lazily parsing method parameters.
- Faster template processing by lazily parsing method parameters.
- DSL: `invocationsOf()` now establishes an additional trace for each invoked method and their owner.

### Fixes
- `--list-entity-types` works again, it was broken in 0.15.0.

Expand Down
4 changes: 4 additions & 0 deletions core/src/main/kotlin/sift/core/api/Action.kt
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ sealed class Action<IN, OUT> {

fun resolveInvocations(elem: MethodNode): Flow<Pair<MethodNode, MethodNode>> {
return ctx.methodsInvokedBy(elem)
// todo: heed inheritance
.asFlow()
.flatMapConcat(::invocations)
.filter { it.type in matched }
Expand All @@ -787,7 +788,10 @@ sealed class Action<IN, OUT> {
.flatMapConcat { mn -> resolveInvocations(mn) }
.toList()
.distinct()
// associate callee methods with invoked methods
.onEach { (old, mn) -> ctx.scopeTransition(old, mn) }
// associate invoked methods with their owners
.onEach { (_, mn) -> ctx.scopeTransition(mn.owner, mn) }
.map { (_, mn) -> mn }

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,6 @@ class SpringBootAxonCqrsTemplate : SystemModelTemplate, SystemModelTemplateServi

override fun template(): Action<Unit, Unit> {

fun Methods.registerAxonHandlers(
ownerType: Entity.Type, // aggregate|projection
handlerAnnotation: Type, // @(Command|Event|Query)Handler
handledType: Entity.Type,
handler: Entity.Type,
) {
annotatedBy(handlerAnnotation)
entity(handler,
property("dot-id-as", withValue(ownerType)),
)

parameters("register $handledType handlers") {
parameter(0) // 1st parameter is command|event|query
property(handler, "type", readType())

// (re-)register command|event|query entity
explodeType(synthesize = true) { // class scope of parameter
entity(handledType)
handledType["received-by"] = handler
}
}
}

fun Classes.registerAggregate(
aggregate: Entity.Type,
Expand Down Expand Up @@ -252,3 +230,28 @@ class SpringBootAxonCqrsTemplate : SystemModelTemplate, SystemModelTemplateServi
E.query to plain(blue2),
)
}



fun Methods.registerAxonHandlers(
ownerType: Entity.Type, // aggregate|projection
handlerAnnotation: Type, // @(Command|Event|Query)Handler
handledType: Entity.Type,
handler: Entity.Type,
) {
annotatedBy(handlerAnnotation)
entity(handler,
property("dot-id-as", withValue(ownerType)),
)

parameters("register $handledType handlers") {
parameter(0) // 1st parameter is command|event|query
property(handler, "type", readType())

// (re-)register command|event|query entity
explodeType(synthesize = true) { // class scope of parameter
entity(handledType)
handledType["received-by"] = handler
}
}
}

0 comments on commit 89171c0

Please sign in to comment.