ores.history.core

Table of Contents

1. Diagram

ores.history.core component diagram

Figure 1: ores.history.core

2. Summary

ores.history.core is the server-only half of ores.history: a dispatch_registry that looks up a caller-registered history provider function by entity_type — the same composed-registrar meta-pattern (Entity-composed registrars) applied as a runtime lookup table instead of N separate subject subscriptions — and the NATS handler/registrar glue that subscribes the single history.v1.get subject.

This layer depends on ores.database=/=ores.security directly: it is server-only glue no client ever touches, and every service that registers a history_provider already links both to do anything else. history_handler resolves each request via make_request_context() exactly like every other NATS handler in the codebase, so a provider receives the same fully-scoped database::context (tenant, party, roles, workspace) any other subject's handler would get — no bespoke auth-context threading.

3. Inputs

  • Per-entity history providers — std::function<std::vector<entity_history_version>(const database::context& ctx, const std::string& entity_id)> — registered by each domain service/component at startup, keyed by that entity's entity_type_of() string. ctx is the same fully-resolved context any other handler in that service would use — a provider calls its own repository/service with it exactly like every other handler does, no unpacking required.
  • A get_entity_history_request (entity_type, entity_id) arriving on the shared history.v1.get NATS subject.

4. Outputs

  • The get_entity_history_response from ores.history.api, published back on the request's reply subject.

5. Entry points

  • include/ores.history.core/service/dispatch_registry.hpp — the server-side registry: register_history_provider(entity_type, fn) and dispatch(request, ctx).
  • include/ores.history.core/messaging/history_handler.hpp — the NATS auth/decode/dispatch/reply glue shared by every entity, resolving each request via make_request_context().
  • include/ores.history.core/messaging/registrar.hpp — register_history_handlers(nats, registry, queue_group, ctx, verifier), subscribing the single history.v1.get subject to a history_handler backed by a caller-owned dispatch_registry. Call once per service process, after registering that service's own entities' providers.

6. Dependencies

  • ores.history.api — the wire types and build_entity_history_versions() every provider uses.
  • ores.database / ores.security — database::context and jwt_authenticator.
  • ores.nats / ores.service / ores.logging — the NATS subscribe/decode/reply plumbing.

7. Build dependencies

What the shared profile cannot know, declared here rather than hand-edited into the generated build file. Each block is spliced into its generated file after the profile's baseline.

8. See also

9. Test dependencies

The suites link what the profile cannot know about.

target_link_libraries(${lib_target_name}
    PUBLIC
        ores.history.api.lib
        ores.database.lib
        ores.logging.lib
        ores.nats.lib
        ores.security.lib
        ores.service.lib)
target_link_libraries(${tests_target_name}
    PRIVATE
        ${lib_target_name}
        ores.utility.lib
        ores.testing.lib
        ores.logging.lib
        Catch2::Catch2
        faker-cxx::faker-cxx
        Threads::Threads)

Emacs 29.3 (Org mode 9.6.15)