Skip to content

Commit 4b59fe8

Browse files
authored
feat(server): /flows/:flowName returns both spec and schema with fp (#588)
1 parent 0f97c6f commit 4b59fe8

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::prelude::*;
22

33
use crate::{lib_context::LibContext, service};
4-
use axum::{routing, Router};
4+
use axum::{Router, routing};
55
use tower::ServiceBuilder;
66
use tower_http::{
77
cors::{AllowOrigin, CorsLayer},
@@ -47,7 +47,7 @@ pub async fn init_server(
4747
.route("/flows", routing::get(service::flows::list_flows))
4848
.route(
4949
"/flows/:flowInstName",
50-
routing::get(service::flows::get_flow_spec),
50+
routing::get(service::flows::get_flow),
5151
)
5252
.route(
5353
"/flows/:flowInstName/schema",

src/service/flows.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use crate::execution::{evaluator, indexing_status, memoization, row_indexer, sta
44
use crate::lib_context::LibContext;
55
use crate::{base::schema::FlowSchema, ops::interface::SourceExecutorListOptions};
66
use axum::{
7+
Json,
78
extract::{Path, State},
89
http::StatusCode,
9-
Json,
1010
};
1111
use axum_extra::extract::Query;
1212

@@ -18,20 +18,39 @@ pub async fn list_flows(
1818
))
1919
}
2020

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

29-
pub async fn get_flow_schema(
29+
#[derive(Serialize)]
30+
pub struct GetFlowResponse {
31+
flow_spec: spec::FlowInstanceSpec,
32+
data_schema: FlowSchema,
33+
fingerprint: utils::fingerprint::Fingerprint,
34+
}
35+
36+
pub async fn get_flow(
3037
Path(flow_name): Path<String>,
3138
State(lib_context): State<Arc<LibContext>>,
32-
) -> Result<Json<FlowSchema>, ApiError> {
39+
) -> Result<Json<GetFlowResponse>, ApiError> {
3340
let flow_ctx = lib_context.get_flow_context(&flow_name)?;
34-
Ok(Json(flow_ctx.flow.data_schema.clone()))
41+
let flow_spec = flow_ctx.flow.flow_instance.clone();
42+
let data_schema = flow_ctx.flow.data_schema.clone();
43+
let fingerprint = utils::fingerprint::Fingerprinter::default()
44+
.with(&flow_spec)
45+
.map_err(|e| api_error!("failed to fingerprint flow spec: {e}"))?
46+
.with(&data_schema)
47+
.map_err(|e| api_error!("failed to fingerprint data schema: {e}"))?
48+
.into_fingerprint();
49+
Ok(Json(GetFlowResponse {
50+
flow_spec,
51+
data_schema,
52+
fingerprint,
53+
}))
3554
}
3655

3756
#[derive(Deserialize)]

0 commit comments

Comments
 (0)