Skip to content

Commit 5617376

Browse files
committed
hook fork logic to libsql configurators
1 parent 72849a4 commit 5617376

File tree

2 files changed

+15
-45
lines changed

2 files changed

+15
-45
lines changed

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

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ use std::sync::Arc;
55

66
use futures::prelude::Future;
77
use libsql_sys::name::NamespaceResolver;
8-
use libsql_sys::wal::either::Either;
98
use libsql_wal::io::StdIO;
109
use libsql_wal::registry::WalRegistry;
11-
use libsql_wal::storage::backend::Backend;
1210
use libsql_wal::wal::LibsqlWalManager;
1311
use tokio::task::JoinSet;
1412

@@ -267,38 +265,15 @@ impl ConfigureNamespace for LibsqlPrimaryConfigurator {
267265
&'a self,
268266
from_ns: &'a Namespace,
269267
_from_config: MetaStoreHandle,
270-
_to_ns: NamespaceName,
271-
_to_config: MetaStoreHandle,
272-
timestamp: Option<chrono::prelude::NaiveDateTime>,
273-
_store: NamespaceStore,
268+
to_ns: NamespaceName,
269+
to_config: MetaStoreHandle,
270+
timestamp: Option<DateTime<Utc>>,
271+
store: NamespaceStore,
274272
) -> Pin<Box<dyn Future<Output = crate::Result<Namespace>> + Send + 'a>> {
275-
Box::pin(async move {
276-
match self.registry.storage() {
277-
Either::A(s) => {
278-
match timestamp {
279-
Some(ts) => {
280-
let ns: libsql_sys::name::NamespaceName = from_ns.name().clone().into();
281-
let _key = s
282-
.backend()
283-
.find_segment(
284-
&s.backend().default_config(),
285-
&ns,
286-
libsql_wal::storage::backend::FindSegmentReq::Timestamp(
287-
ts.and_utc(),
288-
),
289-
)
290-
.await
291-
.unwrap();
292-
todo!()
293-
}
294-
// find the most recent frame_no
295-
None => todo!("fork from most recent"),
296-
};
297-
}
298-
Either::B(_) => {
299-
todo!("cannot fork without storage");
300-
}
301-
}
302-
})
273+
let registry = self.registry.clone();
274+
let base_path = &self.base.base_path;
275+
Box::pin(super::libsql_fork::libsql_wal_fork(
276+
registry, base_path, from_ns, to_ns, to_config, timestamp, store,
277+
))
303278
}
304279
}

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,16 @@ impl ConfigureNamespace for LibsqlSchemaConfigurator {
160160
fn fork<'a>(
161161
&'a self,
162162
from_ns: &'a Namespace,
163-
from_config: MetaStoreHandle,
163+
_from_config: MetaStoreHandle,
164164
to_ns: NamespaceName,
165165
to_config: MetaStoreHandle,
166-
timestamp: Option<chrono::prelude::NaiveDateTime>,
166+
timestamp: Option<DateTime<Utc>>,
167167
store: NamespaceStore,
168168
) -> std::pin::Pin<Box<dyn Future<Output = crate::Result<Namespace>> + Send + 'a>> {
169-
Box::pin(super::fork::fork(
170-
from_ns,
171-
from_config,
172-
to_ns,
173-
to_config,
174-
timestamp,
175-
store,
176-
&self.primary_config,
177-
self.base.base_path.clone(),
169+
let registry = self.registry.clone();
170+
let base_path = &self.base.base_path;
171+
Box::pin(super::libsql_fork::libsql_wal_fork(
172+
registry, base_path, from_ns, to_ns, to_config, timestamp, store,
178173
))
179174
}
180175
}

0 commit comments

Comments
 (0)