-
Notifications
You must be signed in to change notification settings - Fork 1
AF5 model inspection - expose AF5 entity inspection over RSocket #146
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
Open
stefanmirkovic
wants to merge
14
commits into
main
Choose a base branch
from
feature/af5-model-inspection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c908445
AF5 model inspection - expose AF5 entity inspection over RSocket
stefanmirkovic ee73c81
AF5 model inspection - support compound ids and multi-tag entities vi…
stefanmirkovic 8602b70
Merge remote-tracking branch 'origin/main' into feature/af5-model-ins…
stefanmirkovic c278643
return back components for client
stefanmirkovic 796ee60
Merge remote-tracking branch 'origin/main' into feature/af5-model-ins…
stefanmirkovic 989927a
Address PR review comments
stefanmirkovic 9ee6d08
Drive model inspection through real UnitOfWork and support modules
CodeDrivenMitch 22023b1
Merge pull request #153 from AxonIQ/feature/af5-model-inspection-mitc…
stefanmirkovic 3418c69
Cap timeline event payloads at 5 KB and state snapshots at 20 KB so a…
stefanmirkovic 00210c0
Merge remote-tracking branch 'origin/main' into feature/af5-model-ins…
stefanmirkovic 4fc4586
Drop redundant stateBefore on non-leading timeline entries since the …
stefanmirkovic 86eee03
Wire DomainEventAccessMode through to RSocketModelInspectionResponder…
stefanmirkovic 4963071
Merge remote-tracking branch 'origin/main' into feature/af5-model-ins…
stefanmirkovic 8634463
Register FULL access mode in nested-module test
stefanmirkovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
framework-client-api/src/main/java/io/axoniq/platform/framework/api/modelApi.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * Copyright (c) 2022-2026. AxonIQ B.V. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.axoniq.platform.framework.api | ||
|
|
||
| data class RegisteredEntitiesResult( | ||
| val entities: List<RegisteredEntityInfo> | ||
| ) | ||
|
|
||
| data class RegisteredEntityInfo( | ||
| val entityType: String, | ||
| /** | ||
| * All id types registered for this entity. AF5 entities can be addressed by multiple | ||
| * id types (e.g. one per command in a build agent), each producing different criteria. | ||
| * The frontend should let the user pick which id type to query against. | ||
| */ | ||
| val idTypes: List<IdType>, | ||
| ) | ||
|
|
||
| data class IdType( | ||
| /** Fully qualified Java type name of the id class. */ | ||
| val type: String, | ||
| /** | ||
| * Structural descriptors of the id class's properties. Empty for "simple" types | ||
| * (String, primitives, UUID, etc.) — frontend renders a single text input. Populated | ||
| * for compound types (records / data classes / plain objects) — frontend renders one | ||
| * input per descriptor and sends the entityId as a JSON object keyed by descriptor names. | ||
| * Only 1-deep properties are described; nested objects are exposed as type "object" and | ||
| * left for the user to provide as raw JSON. | ||
| */ | ||
| val idFields: List<IdFieldDescriptor> = emptyList(), | ||
| ) | ||
|
|
||
| data class IdFieldDescriptor( | ||
| val name: String, | ||
| /** Normalized form-friendly type: "string", "number", "boolean", "uuid", or "object". */ | ||
| val type: String, | ||
| /** Fully qualified Java type name, useful for diagnostics / future extensions. */ | ||
| val javaType: String, | ||
| ) | ||
|
|
||
| data class ModelDomainEventsQuery( | ||
| val entityType: String, | ||
| val entityId: String, | ||
| /** FQ Java type name of the id type the user selected (must match one of [RegisteredEntityInfo.idTypes].type). */ | ||
| val idType: String, | ||
| val page: Int = 0, | ||
| val pageSize: Int = 10, | ||
| ) | ||
|
|
||
| data class ModelEntityStateAtSequenceQuery( | ||
| val entityType: String, | ||
| val entityId: String, | ||
| /** FQ Java type name of the id type the user selected. */ | ||
| val idType: String, | ||
| val maxSequenceNumber: Long = 0, | ||
| ) | ||
|
|
||
| data class ModelTimelineQuery( | ||
| val entityType: String, | ||
| val entityId: String, | ||
| /** FQ Java type name of the id type the user selected. */ | ||
| val idType: String, | ||
| val offset: Int = 0, | ||
| val limit: Int = 100, | ||
| ) | ||
|
|
||
| data class ModelTimelineResult( | ||
| val entityType: String, | ||
| val entityId: String, | ||
| val entries: List<ModelTimelineEntry>, | ||
| val offset: Int = 0, | ||
| val totalEvents: Int, | ||
| val truncated: Boolean, | ||
| ) | ||
|
|
||
| data class ModelTimelineEntry( | ||
| val sequenceNumber: Long, | ||
| /** | ||
| * ISO-8601 formatted timestamp (from [java.time.Instant.toString]). | ||
| * String is used here — instead of [java.time.Instant] — to avoid ambiguity in how | ||
| * the different serializers (CBOR on the RSocket leg, Jackson on the query-handler leg) | ||
| * encode the Instant: some emit an epoch-seconds number, which the frontend would | ||
| * then incorrectly treat as milliseconds. | ||
| */ | ||
| val timestamp: String, | ||
| val eventType: String, | ||
| val eventPayload: String?, | ||
| val stateBefore: String?, | ||
| val stateAfter: String?, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...t/src/main/java/io/axoniq/platform/framework/eventsourcing/AxoniqPlatformEntityEvolver.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * Copyright (c) 2022-2026. AxonIQ B.V. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.axoniq.platform.framework.eventsourcing | ||
|
|
||
| import org.axonframework.messaging.core.Context | ||
| import org.axonframework.messaging.core.unitofwork.ProcessingContext | ||
| import org.axonframework.messaging.eventhandling.EventMessage | ||
| import org.axonframework.modelling.EntityEvolver | ||
| import java.util.function.BiConsumer | ||
|
|
||
| /** | ||
| * Wraps the underlying [EntityEvolver] of an [org.axonframework.eventsourcing.EventSourcingRepository] | ||
| * so that inspection-time replay can fire BEFORE/AFTER hooks per event without reimplementing | ||
| * AF5's dispatch. | ||
| * | ||
| * The hooks are no-ops unless the matching [Context.ResourceKey] resources are present on the | ||
| * [ProcessingContext], so command handling and normal event sourcing go through unchanged. | ||
| * | ||
| * Constructed by [AxoniqPlatformModelInspectionEnhancer], which detects the inner | ||
| * [org.axonframework.eventsourcing.EventSourcingRepository] in the decorator chain and reconstructs | ||
| * it with this wrapper substituted for its `entityEvolver` argument. | ||
| */ | ||
| class AxoniqPlatformEntityEvolver<E : Any>( | ||
| private val delegate: EntityEvolver<E>, | ||
| ) : EntityEvolver<E> { | ||
|
|
||
| companion object { | ||
| /** Called before [delegate.evolve]. Receives the event and the pre-evolve entity state. */ | ||
| val BEFORE_CONSUMER: Context.ResourceKey<BiConsumer<EventMessage, Any?>> = | ||
| Context.ResourceKey.withLabel("AxoniqPlatformEntityEvolver.BEFORE_CONSUMER") | ||
|
|
||
| /** Called after [delegate.evolve]. Receives the event and the post-evolve entity state. */ | ||
| val AFTER_CONSUMER: Context.ResourceKey<BiConsumer<EventMessage, Any?>> = | ||
| Context.ResourceKey.withLabel("AxoniqPlatformEntityEvolver.AFTER_CONSUMER") | ||
|
|
||
| /** | ||
| * Zero-based event index — when present, [evolve] returns the current entity unchanged | ||
| * once it has applied this many events. Lets inspection reconstruct state up to a given | ||
| * sequence without doing the bookkeeping outside the framework. | ||
| */ | ||
| val MAX_INDEX: Context.ResourceKey<Long> = | ||
| Context.ResourceKey.withLabel("AxoniqPlatformEntityEvolver.MAX_INDEX") | ||
|
|
||
| /** Internal counter advanced by [evolve] when [MAX_INDEX] is set. */ | ||
| val INDEX_COUNTER: Context.ResourceKey<LongCounter> = | ||
| Context.ResourceKey.withLabel("AxoniqPlatformEntityEvolver.INDEX_COUNTER") | ||
| } | ||
|
|
||
| /** Tiny mutable holder so we can advance the index without re-putting a Long resource each call. */ | ||
| class LongCounter(var value: Long = 0) | ||
|
|
||
| override fun evolve(entity: E, event: EventMessage, context: ProcessingContext): E { | ||
| val maxIndex = context.getResource(MAX_INDEX) | ||
| if (maxIndex != null) { | ||
| val counter = context.computeResourceIfAbsent(INDEX_COUNTER) { LongCounter() } | ||
| if (counter.value > maxIndex) { | ||
| return entity | ||
| } | ||
| counter.value++ | ||
| } | ||
| context.getResource(BEFORE_CONSUMER)?.accept(event, entity) | ||
| val result = delegate.evolve(entity, event, context) | ||
| context.getResource(AFTER_CONSUMER)?.accept(event, result) | ||
| return result | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.