Expand description
Data-layer connectors for klauthed services.
This crate turns the typed configuration sections from
klauthed_core::config into real, connected resources — database
pools, cache clients — so a service never hand-rolls connection wiring.
Every backend lives behind a Cargo feature, so a service compiles only the drivers it actually uses:
(Plain code spans below rather than intra-doc links, since these items are feature-gated and absent from a default-feature doc build.)
| Feature | Provides |
|---|---|
postgres | db::connect for PostgreSQL (implies sql) |
mysql | db::connect for MySQL/MariaDB (implies sql) |
sqlite | db::connect for SQLite (implies sql) |
redis | cache::connect_redis |
cache-memory | cache::build_memory_cache (moka, in-process) |
nats | messaging::connect_nats (async-nats) |
rabbitmq | messaging::connect_rabbitmq (lapin / AMQP) |
kafka | messaging::connect_kafka (rskafka, pure Rust) |
storage | storage::connect for local filesystem |
storage-s3 | storage::connect for S3 / S3-compatible |
storage-gcs | storage::connect for Google Cloud Storage |
storage-azure | storage::connect for Azure Blob Storage |
mongodb | db::mongo::connect for MongoDB |
use klauthed_core::config::Config;
let config = Config::load().await?;
let pool = klauthed_data::db::connect(&config.database()?).await?;Re-exports§
pub use error::DataError;pub use migrate::Migration;pub use migrate::Migrator;pub use starter::DataStarter;pub use idempotency::IdempotencyRecord;pub use idempotency::IdempotencyStatus;pub use idempotency::IdempotencyStore;pub use idempotency::InMemoryIdempotencyStore;pub use idempotency::Outcome;pub use locks::InMemoryLockManager;pub use locks::LockGuard;pub use locks::LockManager;pub use locks::LockToken;pub use outbox::InMemoryOutbox;pub use outbox::Outbox;pub use outbox::OutboxEntry;pub use outbox::OutboxId;pub use outbox::SqlOutbox;pub use locks::redis::RedisLockManager;pub use idempotency::redis::RedisIdempotencyStore;pub use outbox::MongoOutbox;pub use locks::mongo::MongoLockManager;pub use idempotency::mongo::MongoIdempotencyStore;
Modules§
- cache
- Cache connections from a
CacheConfig. - db
- Database connectors.
- error
- The crate’s
DataErrortype. - eventbus
- Event bus — reserved for future implementation.
- idempotency
- Idempotency keys.
- locks
- Distributed locks.
- messaging
- Messaging / event-bus connections from a
MessagingConfig. - migrate
- Embedded, versioned schema migrations over a relational pool
(
feature = "sql"). - outbox
- Transactional outbox.
- pagination
- Pagination — offset, cursor, and keyset strategies.
- rate_
limit - Rate limiting with a pluggable backend and algorithm.
- saga
- Saga orchestration — reserved for future implementation.
- starter
DataStarter— wire data-layer resources from config into anAppContext(feature = "sql").- storage
- Object storage connections from a
StorageConfig. - transaction
- Unit-of-work transaction abstraction.