1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! `RequestCacheDescriptor` -- compile-time metadata for a `#[request_cache]`
//! resolver.
//!
//! A sibling to `AuthUser`: this is the *compile-time* contract the
//! `#[request_cache]` proc-macro generates against. This descriptor is pure
//! data -- a `&'static` const describing which resolvers are memoized, and
//! readable without running the application.
//!
//! Nothing reads it yet. `ModuleDescriptor` has no field for request caches,
//! so the descriptor does not reach the Unified Application Graph and no
//! command reports on it. That is worth stating plainly rather than naming a
//! consumer that does not exist: the value here is the compile-time contract
//! the macro checks against, and a reporting surface is still to be built.
//!
//! # No runtime here
//!
//! This module carries NO runtime behavior -- no memoization, no locking.
//! It is metadata only, matching the one-file-one-responsibility law: the
//! descriptor (this file) is separate from the store that does the
//! remembering, which lives next door in
//! [`request_cache_store`](super::request_cache_store). Tooling that only
//! needs to *report* which resolvers are memoized reads this file and never
//! touches the store.
//!
//! # Example
//!
//! ```
//! // Generated by `#[request_cache]` in arcature-macros:
//! pub const LOAD_PROFILE_REQUEST_CACHE: ::arcature::RequestCacheDescriptor =
//! ::arcature::RequestCacheDescriptor {
//! name: "load_profile",
//! key_fields: &["user_id"],
//! };
//!
//! // Pure data, readable without running the application -- which is the
//! // whole claim this module makes.
//! assert_eq!(LOAD_PROFILE_REQUEST_CACHE.key_fields, &["user_id"]);
//! ```
/// Compile-time metadata for a per-request memoized resolver.
///
/// The `#[request_cache]` proc-macro generates a `pub const <NAME>_REQUEST_CACHE:
/// RequestCacheDescriptor` for each annotated resolver. The descriptor records
/// the resolver's name and the names of the parameters that form its cache key,
/// so the UAG / Inspector can show "this resolver is memoized per request by
/// `<key_fields>`" without running the resolver.
///
/// The fields are `&'static` so the descriptor is `const`-constructible and
/// lives in the binary (no allocation). A descriptor is *declarative* -- it
/// does not cause memoization; the wrapper the macro generates around the
/// resolver does, against
/// [`RequestCache`](super::request_cache_store::RequestCache). The
/// descriptor is what the graph records.