Expand description
Database layer for LLM Registry
This crate provides database persistence for the LLM Registry system, including:
- Connection pool management with deadpool
- Repository trait abstractions for assets
- PostgreSQL implementation with SQLx
- Event store for audit trails and event sourcing
- Database migrations
- Comprehensive error handling
§Features
- Compile-time verified queries: Using SQLx macros for type-safe SQL
- Connection pooling: Efficient connection management with configurable pools
- Transaction support: ACID guarantees for multi-step operations
- Event sourcing: Complete audit trail of all registry operations
- Flexible search: Full-text search and filtering capabilities
- Dependency tracking: Graph-based dependency management with cycle detection
§Example
use llm_registry_db::{PoolConfig, create_pool, PostgresAssetRepository};
use llm_registry_core::Asset;
// Create a connection pool
let config = PoolConfig::new("postgres://localhost/llm_registry")
.max_connections(10);
let pool = create_pool(&config).await?;
// Create repository
let repo = PostgresAssetRepository::new(pool);
// Use the repository
// let asset = repo.create(my_asset).await?;Re-exports§
pub use cache::CacheConfig;pub use cache::CacheStats;pub use cache::RedisCache;pub use error::DbError;pub use error::DbResult;pub use event_store::EventQuery;pub use event_store::EventQueryResults;pub use event_store::EventStore;pub use event_store::PostgresEventStore;pub use nats_publisher::EventMessage;pub use nats_publisher::NatsEventPublisher;pub use nats_publisher::NatsPublisherConfig;pub use nats_publisher::NatsSubscriberConfig;pub use pool::close_pool;pub use pool::create_pool;pub use pool::get_pool_stats;pub use pool::run_migrations;pub use pool::verify_pool_health;pub use pool::PoolConfig;pub use pool::PoolStats;pub use postgres::PostgresAssetRepository;pub use repository::AssetRepository;pub use repository::SearchQuery;pub use repository::SearchResults;pub use repository::SortField;pub use repository::SortOrder;pub use llm_registry_core;
Modules§
- cache
- Redis-based caching layer
- error
- Database-specific error types and conversions
- event_
store - Event store for registry event persistence and querying
- nats_
publisher - NATS event publisher
- pool
- Database connection pool management
- postgres
- PostgreSQL implementation of AssetRepository
- repository
- Repository trait abstractions for asset persistence
Constants§
- DEFAULT_
DATABASE_ URL_ ENV - Default database URL environment variable name
- VERSION
- Database layer version