aster_forge_config/
lib.rs

1//! Shared runtime configuration primitives for Aster services.
2//!
3//! This crate owns product-neutral configuration mechanics: typed configuration
4//! definitions, registry construction, storage value conversion, in-process
5//! runtime snapshots, reload diffing, and cross-process reload notifications.
6//! Product crates still own their concrete database entities, repositories,
7//! localized labels, config keys, domain-specific normalizers, and any derived
8//! runtime state that is built from configuration values.
9#![cfg_attr(
10    not(test),
11    deny(
12        clippy::unwrap_used,
13        clippy::unreachable,
14        clippy::expect_used,
15        clippy::panic,
16        clippy::unimplemented,
17        clippy::todo
18    )
19)]
20
21pub mod avatar;
22mod error;
23mod notification;
24mod registry;
25mod runtime;
26mod value;
27
28pub use error::{ConfigCoreError, Result};
29#[cfg(feature = "redis-pubsub")]
30pub use notification::RedisConfigChangeNotifier;
31pub use notification::{
32    CONFIG_SYNC_BACKEND_DISABLED, CONFIG_SYNC_BACKEND_REDIS, ConfigChangeEvent,
33    ConfigChangeNotifier, ConfigNotification, ConfigNotificationSource, ConfigReloadDecision,
34    ConfigReloadMessage, ConfigReloadObservation, ConfigReloadObserver, ConfigReloadWorkerConfig,
35    ConfigSyncConfig, ConfigSyncConnectionObservation, ConfigSyncConnectionObserver,
36    ConfigSyncConnectionState, ConfigSyncEndpoint, ConfigSyncRuntime, InMemoryConfigNotifier,
37    SharedConfigChangeNotifier, build_config_sync_runtime,
38    build_config_sync_runtime_with_runtime_id, decode_config_reload_transport_payload,
39    default_config_sync_topic, handle_config_reload_notification, run_config_reload_supervisor,
40    run_config_reload_supervisor_with_observers, run_config_reload_worker,
41    run_config_reload_worker_with_observer,
42};
43pub use registry::{
44    ConfigDefinition, ConfigDependencyValidator, ConfigNormalizer, ConfigRegistry,
45    ConfigSeedRecord, ConfigValueLookup,
46};
47pub use runtime::{
48    AsyncConfigSnapshot, AsyncConfigStore, AsyncRuntimeConfig, RuntimeConfigChange,
49    RuntimeConfigRecord, StoredConfig, SyncConfigSnapshot, SyncRuntimeConfig,
50    normalize_bool_config_value, normalize_bounded_u8_config_value,
51    normalize_bounded_u64_config_value, normalize_finite_f32_config_value,
52    normalize_non_negative_u64_config_value, normalize_positive_u32_config_value,
53    normalize_positive_u64_config_value, normalize_strict_bool_config_value, parse_bool_like_value,
54    parse_bounded_u8, parse_bounded_u64, parse_finite_f32, parse_non_negative_u64,
55    parse_positive_i32, parse_positive_u32, parse_positive_u64, parse_strict_bool_value, read_bool,
56    read_bounded_u8, read_bounded_u64, read_finite_f32, read_non_negative_u64, read_positive_i32,
57    read_positive_u32, read_positive_u64, read_positive_usize,
58};
59pub use value::{
60    ConfigSource, ConfigValue, ConfigValueType, ConfigVisibility, config_value_audit_string,
61    normalize_string_enum_set_selection, parse_single_string_enum_selection,
62    parse_string_array_config_value, parse_string_enum_set_selection, present_config_value,
63    validate_storage_value,
64};
65
66/// Builds a static [`ConfigRegistry`] from a list of [`ConfigDefinition`] items.
67///
68/// Product crates normally wrap this macro in their own module that names
69/// product-specific keys and default functions. Keeping registration declarative
70/// makes it easier for services to hand the same registry to default
71/// initialization, validation, `OpenAPI` presentation, and admin UI metadata.
72#[macro_export]
73macro_rules! define_config_registry {
74    ($vis:vis static $name:ident = [$($definition:expr),* $(,)?];) => {
75        $vis static $name: $crate::ConfigRegistry = $crate::ConfigRegistry::new(&[
76            $($definition),*
77        ]);
78    };
79}