Skip to content

Commit 4993c12

Browse files
committed
PITR fork sketch
1 parent 84f9258 commit 4993c12

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

libsql-server/src/namespace/configurator/libsql_primary.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use std::sync::Arc;
66
use chrono::{DateTime, Utc};
77
use futures::prelude::Future;
88
use libsql_sys::name::NamespaceResolver;
9+
use libsql_sys::wal::either::Either;
910
use libsql_wal::io::StdIO;
1011
use libsql_wal::registry::WalRegistry;
12+
use libsql_wal::storage::backend::Backend;
1113
use libsql_wal::wal::LibsqlWalManager;
1214
use tokio::task::JoinSet;
1315

@@ -264,13 +266,30 @@ impl ConfigureNamespace for LibsqlPrimaryConfigurator {
264266

265267
fn fork<'a>(
266268
&'a self,
267-
_from_ns: &'a Namespace,
269+
from_ns: &'a Namespace,
268270
_from_config: MetaStoreHandle,
269271
_to_ns: NamespaceName,
270272
_to_config: MetaStoreHandle,
271273
timestamp: Option<DateTime<Utc>>,
272274
_store: NamespaceStore,
273275
) -> Pin<Box<dyn Future<Output = crate::Result<Namespace>> + Send + 'a>> {
274-
unimplemented!()
276+
Box::pin(async move {
277+
match self.registry.storage() {
278+
Either::A(s) => {
279+
match timestamp {
280+
Some(ts) => {
281+
let ns: libsql_sys::name::NamespaceName = from_ns.name().clone().into();
282+
let _key = s.backend().find_segment(&s.backend().default_config(), &ns, libsql_wal::storage::backend::FindSegmentReq::Timestamp(ts)).await.unwrap();
283+
todo!()
284+
},
285+
// find the most recent frame_no
286+
None => todo!("fork from most recent"),
287+
};
288+
},
289+
Either::B(_) => {
290+
todo!("cannot fork without storage");
291+
},
292+
}
293+
})
275294
}
276295
}

0 commit comments

Comments
 (0)