Skip to main content

Crate klauthed_data

Crate klauthed_data 

Source
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.)

FeatureProvides
postgresdb::connect for PostgreSQL (implies sql)
mysqldb::connect for MySQL/MariaDB (implies sql)
sqlitedb::connect for SQLite (implies sql)
rediscache::connect_redis
cache-memorycache::build_memory_cache (moka, in-process)
natsmessaging::connect_nats (async-nats)
rabbitmqmessaging::connect_rabbitmq (lapin / AMQP)
kafkamessaging::connect_kafka (rskafka, pure Rust)
storagestorage::connect for local filesystem
storage-s3storage::connect for S3 / S3-compatible
storage-gcsstorage::connect for Google Cloud Storage
storage-azurestorage::connect for Azure Blob Storage
mongodbdb::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 DataError type.
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 an AppContext (feature = "sql").
storage
Object storage connections from a StorageConfig.
transaction
Unit-of-work transaction abstraction.

Type Aliases§

AnyPool