feat(instrumentation-build): generate namespaced instrumentation APIs - #450
Closed
johanpel wants to merge 5 commits into
Closed
feat(instrumentation-build): generate namespaced instrumentation APIs#450johanpel wants to merge 5 commits into
johanpel wants to merge 5 commits into
Conversation
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Contributor
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Schema type paths were added in #449, but
quent-instrumentation-buildtemporarily rejected paths with more than one segment.Flattening paths into Rust identifiers loses segment boundaries. For example, these distinct schema paths:
would both become FooBarBaz. This PR instead preserves the schema structure using Rust modules:
Equal leaf names can therefore coexist naturally:
Generated records, entity markers, event types, reference targets, handle implementations, and
AnyEventenums follow the same module structure. Entity stream names retain the complete schema path, and namespace-localAnyEventenums compose into their parents.Generated instrumentation API
Previously, every entity generated separately named observer and handle types, which could conflict with valid schema types such as
QueryObserverorQueryHandle:The API now uses shared Context and Observer types from quent-instrumentation, plus one generated generic Handle and schema marker types:
Qualified entity paths are used directly as type arguments:
Generated typed observer collections mirror the schema namespace hierarchy. Compile-time
ObserverAccess<E>implementations map each entity to its stored observer without flattened identifiers, runtime downcasts, or tuple indices.Shared context and observer behavior, along with handle state and emission mechanics, now lives in
quent-instrumentation. The generated API retains only schema-dependent markers, event enums, observer collections, and event methods. Each context owns exactly oneObserverInnertransport per entity type, shared by that entity’s observer and handles.Overview of the instrumentation types / traits
Not generated
Context<M>Observer<E>ModelContextInnerContext<M>.EntityObserverInner<T>ObserverAccess<E>Observer<E>.HandleInner<E>EventSender<T>HandleErrorGenerated
{Model}impl Model for {Model}{Model}Observers{Namespace}Observers{Namespace}.impl ObserverAccess<{Namespace}::{Entity}> for {Model}Observers{Namespace}::{Entity}impl Entity for {Namespace}::{Entity}impl Handle<{Namespace}::{Entity}>{Namespace}::{Entity}EventHandle<E>{Namespace}::AnyEvent<'a>Related Issues
Follow-up to #449. Closes #442.
Written by Codex.