klauthed-core
Foundational primitives shared by every klauthed service.
- config — profile-driven configuration. A
Profile(Local/Dev/Test/Staging/Prod) governs which sources are allowed; staging/prod must use Vault (enforced in the builder).ConfigProvideris a trait (file, env, and a built-in Vault client over reqwest behind thevaultfeature), so a service can register its own sources. Theconfig-serverfeature addsConfigServerProvider, which pulls config from a remote config server — defaulting to the klauthed-native format served byklauthed-web's config server, withspring_cloud()/RawJsonmodes for other servers. - wiring — Spring-style application assembly:
AppContext(a type-keyed registry of shared singletons) plus asyncStarter/AppBuilderauto-config, so crates contribute resources (pools, clients) to one composed context. - time — time as an injectable dependency: components take a
Clock(SystemClockin production,FixedClockin tests).Timestamp/Durationare the canonical instant and span types, backed by thetimecrate and fully encapsulated here. - id — typed identifiers (UUID v4/v7, ULID).
- validation — a
Validatetrait + structured validation errors. - context —
RequestContext(request id, principal, tenant, deadline), optionally ambient via a tokio task-local (featuretask-local). - domain / cqrs — building blocks for domain entities and command/query handlers.
Fallible operations return ConfigError (and friends), which implement
klauthed_error::DomainError.
Part of the klauthed rust-libraries workspace.
Browse the API: cargo doc -p klauthed-core --open.
License
Dual-licensed under MIT or Apache-2.0, at your option.