@@ -6,8 +6,10 @@ use std::sync::Arc;
66use chrono:: { DateTime , Utc } ;
77use futures:: prelude:: Future ;
88use libsql_sys:: name:: NamespaceResolver ;
9+ use libsql_sys:: wal:: either:: Either ;
910use libsql_wal:: io:: StdIO ;
1011use libsql_wal:: registry:: WalRegistry ;
12+ use libsql_wal:: storage:: backend:: Backend ;
1113use libsql_wal:: wal:: LibsqlWalManager ;
1214use 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