Skip to main content

Module resolver

Module resolver 

Source
Expand description

Resolver: caching + dedup + dispatch layer between ChartML::fetch and the registered DataSourceProvider implementations (chartml 5.0 phase 3).

The resolver owns:

  • Tier-1 cache — a MemoryBackend always present.
  • Tier-2 cache — optional CacheBackendRef (populated in phase 3b by IndexedDbBackend; phase 3 leaves it None).
  • In-flight tracker — a HashMap<u64, Shared<BoxFuture<...>>> so two concurrent fetches for the same key share one provider invocation.
  • Provider registryHashMap<String, Arc<dyn DataSourceProvider>>, keyed by dispatch slug ("inline", "http", "datasource", …).

Phase 3 leaves ResolverHooks integration as a no-op stub; phase 3c will add hook dispatch without further changes to this file’s structure.

Re-exports§

pub use builtin::HttpProvider;
pub use builtin::InlineProvider;
pub use cache::CacheBackend;
pub use cache::CacheError;
pub use cache::CachedEntry;
pub use cache::MemoryBackend;
pub use cancel::CancellationToken;
pub use hooks::CacheHitEvent;
pub use hooks::CacheMissEvent;
pub use hooks::CacheTier;
pub use hooks::ErrorEvent;
pub use hooks::HooksRef;
pub use hooks::MissReason;
pub use hooks::NullHooks;
pub use hooks::Phase;
pub use hooks::ProgressEvent;
pub use hooks::ResolverHooks;

Modules§

backends
Pluggable persistent CacheBackend implementations (chartml 5.0 phase 3b).
builtin
Built-in providers: InlineProvider and HttpProvider.
cache
Pluggable caching for fetched provider results.
cancel
Cooperative cancellation for in-flight provider work.
hooks
Observability for the resolver pipeline (chartml 5.0 phase 3c).

Structs§

CacheConfig
Parsed cache config. Built from spec::source::CacheConfig (which carries the raw YAML strings) so the resolver doesn’t have to re-parse humantime formats on every fetch.
FetchBatchResult
Batch-oriented provider response. Carries multiple RecordBatches with a shared schema, allowing the transform layer to register them into MemTable without concatenation.
FetchRequest
Per-source request context. Carries the resolved spec (params already substituted) plus cache + header + namespace + cancellation hints.
FetchResult
Provider response. Clone is required because futures::future::Shared (used for in-flight dedup) takes a Future<Output: Clone>. DataTable is Arc-backed so cloning is cheap.
ResolveOutcome
Outcome of a Resolver::fetch call: the provider’s result PLUS whether the value came from a cache tier or a fresh provider invocation.
Resolver
Provider dispatch + cache + dedup orchestration.

Enums§

FetchError
Provider failures. Clone matches FetchResult so Shared can clone the error when multiple in-flight callers receive the same outcome.

Constants§

DEFAULT_TTL
Default TTL applied when a spec doesn’t declare one. Five minutes matches the JS middleware’s CACHE_TTL_DEFAULT_MS.
TAG_NAMESPACE_PREFIX
Tag prefix for namespace-based bulk invalidation.
TAG_SLUG_PREFIX
Tag prefix for source-slug-based bulk invalidation. Public so consumers computing tags out-of-band (e.g., a custom CacheBackend that wants to pre-populate entries) match the resolver’s wire format exactly.

Traits§

DataSourceProvider
Provider dispatch + fetch trait. Host apps implement this for their custom data sources (BigQuery, Snowflake, internal REST APIs, …) and register them via ChartML::register_provider(kind, provider).

Type Aliases§

CacheBackendRef
Public alias for the shared-ownership wrapper around a CacheBackend trait object. Arc<dyn CacheBackend> on native, Rc<dyn CacheBackend> on WASM — mirrors the SharedRef story so wasm32 consumers can hand off !Send backends (e.g. [backends::indexeddb::IndexedDbBackend]) without tripping clippy::arc_with_non_send_sync.
ResolverRef
Public alias for the shared-ownership wrapper around Resolver. Arc on native (so consumers using tokio::spawn can move resolver handles across task boundaries) and Rc on WASM (where the resolver’s inflight map is inherently ?Send, so an Arc would be both incorrect and rejected by clippy::arc_with_non_send_sync). Returned by ChartML::resolver() and accepted by every host that wants a long-lived handle for the bulk invalidate* API.
SharedRef
Cfg-gated shared-ownership pointer. Arc<T> on native (so handles can move across tokio::spawn task boundaries), Rc<T> on WASM (where wasm32-unknown-unknown is single-threaded and the resolver’s internals are ?Send, so an Arc would be both incorrect and rejected by clippy::arc_with_non_send_sync).