Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::*;

use crate::{lib_context::LibContext, service};
use axum::{routing, Router};
use axum::{Router, routing};
use tower::ServiceBuilder;
use tower_http::{
cors::{AllowOrigin, CorsLayer},
Expand Down Expand Up @@ -47,7 +47,7 @@ pub async fn init_server(
.route("/flows", routing::get(service::flows::list_flows))
.route(
"/flows/:flowInstName",
routing::get(service::flows::get_flow_spec),
routing::get(service::flows::get_flow),
)
.route(
"/flows/:flowInstName/schema",
Expand Down
33 changes: 26 additions & 7 deletions src/service/flows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::execution::{evaluator, indexing_status, memoization, row_indexer, sta
use crate::lib_context::LibContext;
use crate::{base::schema::FlowSchema, ops::interface::SourceExecutorListOptions};
use axum::{
Json,
extract::{Path, State},
http::StatusCode,
Json,
};
use axum_extra::extract::Query;

Expand All @@ -18,20 +18,39 @@ pub async fn list_flows(
))
}

pub async fn get_flow_spec(
pub async fn get_flow_schema(
Path(flow_name): Path<String>,
State(lib_context): State<Arc<LibContext>>,
) -> Result<Json<spec::FlowInstanceSpec>, ApiError> {
) -> Result<Json<FlowSchema>, ApiError> {
let flow_ctx = lib_context.get_flow_context(&flow_name)?;
Ok(Json(flow_ctx.flow.flow_instance.clone()))
Ok(Json(flow_ctx.flow.data_schema.clone()))
}

pub async fn get_flow_schema(
#[derive(Serialize)]
pub struct GetFlowResponse {
flow_spec: spec::FlowInstanceSpec,
data_schema: FlowSchema,
fingerprint: utils::fingerprint::Fingerprint,
}

pub async fn get_flow(
Path(flow_name): Path<String>,
State(lib_context): State<Arc<LibContext>>,
) -> Result<Json<FlowSchema>, ApiError> {
) -> Result<Json<GetFlowResponse>, ApiError> {
let flow_ctx = lib_context.get_flow_context(&flow_name)?;
Ok(Json(flow_ctx.flow.data_schema.clone()))
let flow_spec = flow_ctx.flow.flow_instance.clone();
let data_schema = flow_ctx.flow.data_schema.clone();
let fingerprint = utils::fingerprint::Fingerprinter::default()
.with(&flow_spec)
.map_err(|e| api_error!("failed to fingerprint flow spec: {e}"))?
.with(&data_schema)
.map_err(|e| api_error!("failed to fingerprint data schema: {e}"))?
.into_fingerprint();
Ok(Json(GetFlowResponse {
flow_spec,
data_schema,
fingerprint,
}))
}

#[derive(Deserialize)]
Expand Down