Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dashboard-srv): support list sources #5098

Merged
merged 2 commits into from
Sep 5, 2022
Merged
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
31 changes: 29 additions & 2 deletions src/meta/src/dashboard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ pub type Service<S> = Arc<DashboardService<S>>;

mod handlers {
use axum::Json;
use risingwave_pb::catalog::Table;
use itertools::Itertools;
use risingwave_pb::catalog::{Source, Table};
use risingwave_pb::common::WorkerNode;
use risingwave_pb::meta::ActorLocation;
use risingwave_pb::meta::{ActorLocation, TableFragments as ProstTableFragments};
use risingwave_pb::stream_plan::StreamActor;
use serde_json::json;

use super::*;
use crate::model::TableFragments;

pub struct DashboardError(anyhow::Error);
pub type Result<T> = std::result::Result<T, DashboardError>;
Expand Down Expand Up @@ -98,6 +100,15 @@ mod handlers {
Ok(Json(materialized_views))
}

pub async fn list_sources<S: MetaStore>(
Extension(srv): Extension<Service<S>>,
) -> Result<Json<Vec<Source>>> {
use crate::model::MetadataModel;

let sources = Source::list(&*srv.meta_store).await.map_err(err)?;
Ok(Json(sources))
}

pub async fn list_actors<S: MetaStore>(
Extension(srv): Extension<Service<S>>,
) -> Result<Json<Vec<ActorLocation>>> {
Expand Down Expand Up @@ -133,6 +144,20 @@ mod handlers {

Ok(Json(table_fragments))
}

pub async fn list_fragments<S: MetaStore>(
Extension(srv): Extension<Service<S>>,
) -> Result<Json<Vec<ProstTableFragments>>> {
use crate::model::MetadataModel;

let table_fragments = TableFragments::list(&*srv.meta_store)
.await
.map_err(err)?
.into_iter()
.map(|x| x.to_protobuf())
.collect_vec();
Ok(Json(table_fragments))
}
}

impl<S> DashboardService<S>
Expand All @@ -147,7 +172,9 @@ where
.route("/clusters/:ty", get(list_clusters::<S>))
.route("/actors", get(list_actors::<S>))
.route("/fragments", get(list_table_fragments::<S>))
.route("/fragments2", get(list_fragments::<S>))
.route("/materialized_views", get(list_materialized_views::<S>))
.route("/sources", get(list_sources::<S>))
.layer(
ServiceBuilder::new()
.layer(AddExtensionLayer::new(srv.clone()))
Expand Down