Configuration
SlateDB configuration shows up in three main places:
Settingsholds serializable runtime settings.- Builders such as
DbBuilderandDbReaderBuilderhavewith_*functions to handle complex types and dependency injection. - Operation-specific option types such as
ReadOptionsandWriteOptions.
For the complete configuration surface and current defaults, read the slatedb::config rustdoc.
Example
Section titled “Example”This example shows all three configuration layers in one place:
use slatedb::{ config::{DbReaderOptions, ReadOptions, Settings}, db_cache::foyer::FoyerCache, object_store::{memory::InMemory, ObjectStore}, Db, DbReader, Error,};use std::sync::Arc;use std::time::Duration;
#[tokio::main]async fn main() -> Result<(), Error> { let object_store: Arc<dyn ObjectStore> = Arc::new(InMemory::new());
// 1. Serializable runtime settings. let mut settings = Settings::default(); settings.flush_interval = Some(Duration::from_millis(250));
// 2. Builder configuration for process-local components and wiring. let db = Db::builder("example", Arc::clone(&object_store)) .with_settings(settings) .with_db_cache(Arc::new(FoyerCache::new())) .build() .await?;
// 3. Per-call options for one operation. let _value = db .get_with_options( b"key", &ReadOptions::default().with_cache_blocks(false), ) .await?;
// Reader-specific options configure the DbReader instance itself. let mut reader_options = DbReaderOptions::default(); reader_options.skip_wal_replay = true;
let _reader = DbReader::builder("example", object_store) .with_options(reader_options) .build() .await?;
Ok(())}