Skip to content

Commit

Permalink
feat(dashboard-srv): support list sources (#5098)
Browse files Browse the repository at this point in the history
Signed-off-by: xxchan <[email protected]>

Signed-off-by: xxchan <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
xxchan and mergify[bot] authored Sep 5, 2022
1 parent fa5206c commit a14d883
Showing 1 changed file with 29 additions and 2 deletions.
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

0 comments on commit a14d883

Please sign in to comment.