Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions libsql-server/src/http/admin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ where
};
let router = axum::Router::new()
.route("/", get(handle_get_index))
.route("/v1/namespaces", get(handle_get_namespaces))
.route(
"/v1/namespaces/:namespace/config",
get(handle_get_config).post(handle_post_config),
Expand Down Expand Up @@ -238,6 +239,19 @@ async fn handle_get_index() -> &'static str {
"Welcome to the sqld admin API"
}

async fn handle_get_namespaces<C: Connector>(
State(app_state): State<Arc<AppState<C>>>,
) -> Json<Vec<String>> {
let store = app_state.namespaces.meta_store();
let namespaces = store
.list_names()
.await
.iter()
.map(|n| n.to_string())
.collect();
Json(namespaces)
}

async fn handle_metrics(State(metrics): State<Metrics>) -> String {
metrics.render()
}
Expand Down
4 changes: 4 additions & 0 deletions libsql-server/src/namespace/meta_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,10 @@ impl MetaStore {
self.inner.configs.lock().await.contains_key(namespace)
}

pub async fn list_names(&self) -> Vec<NamespaceName> {
self.inner.configs.lock().await.keys().cloned().collect()
}

pub(crate) async fn shutdown(&self) -> crate::Result<()> {
let replicator = self.inner.wal_manager.wrapper().as_ref();

Expand Down
Loading