deltalake_lakefs/
lib.rs

1//! LakeFS and similar tooling for delta-rs
2//!
3//! This module also contains the [LakeFSLogStore] implementation for delta operations executed in transaction branches
4//! where deltalake commits only happen when the branch can be safely merged.
5
6pub mod client;
7pub mod errors;
8pub mod execute;
9pub mod logstore;
10pub mod storage;
11use deltalake_core::logstore::{logstore_factories, LogStore, LogStoreFactory};
12use deltalake_core::logstore::{object_store_factories, ObjectStoreRef, StorageConfig};
13use deltalake_core::DeltaResult;
14pub use execute::LakeFSCustomExecuteHandler;
15use logstore::lakefs_logstore;
16use std::sync::Arc;
17use storage::LakeFSObjectStoreFactory;
18use storage::S3StorageOptionsConversion;
19use tracing::debug;
20use url::Url;
21
22#[derive(Clone, Debug, Default)]
23pub struct LakeFSLogStoreFactory {}
24
25impl S3StorageOptionsConversion for LakeFSLogStoreFactory {}
26
27impl LogStoreFactory for LakeFSLogStoreFactory {
28    fn with_options(
29        &self,
30        store: ObjectStoreRef,
31        location: &Url,
32        config: &StorageConfig,
33    ) -> DeltaResult<Arc<dyn LogStore>> {
34        let options = StorageConfig::parse_options(self.with_env_s3(&config.raw.clone()))?;
35        debug!("LakeFSLogStoreFactory has been asked to create a LogStore");
36        lakefs_logstore(store, location, &options)
37    }
38}
39
40/// Register an [ObjectStoreFactory] for common LakeFS [Url] schemes
41pub fn register_handlers(_additional_prefixes: Option<Url>) {
42    let object_stores = Arc::new(LakeFSObjectStoreFactory::default());
43    let log_stores = Arc::new(LakeFSLogStoreFactory::default());
44    let scheme = "lakefs";
45    let url = Url::parse(&format!("{scheme}://")).unwrap();
46    object_store_factories().insert(url.clone(), object_stores.clone());
47    logstore_factories().insert(url.clone(), log_stores.clone());
48}