1- use std :: collections :: HashMap ;
1+ use crate :: prelude :: * ;
22use std:: fmt:: Debug ;
33use std:: hash:: Hash ;
4- use std:: sync:: Arc ;
5-
6- use anyhow:: Result ;
7- use axum:: async_trait;
8- use futures:: future:: BoxFuture ;
9- use serde:: de:: DeserializeOwned ;
10- use serde:: Serialize ;
114
125use super :: interface:: * ;
136use super :: registry:: * ;
147use crate :: api_bail;
158use crate :: api_error;
169use crate :: base:: schema:: * ;
1710use crate :: base:: spec:: * ;
18- use crate :: base:: value;
1911use crate :: builder:: plan:: AnalyzedValueMapping ;
2012use crate :: setup;
2113// SourceFactoryBase
@@ -272,6 +264,13 @@ impl<T: SimpleFunctionFactoryBase> SimpleFunctionFactory for T {
272264 }
273265}
274266
267+ pub struct ExportTargetBuildOutput < F : StorageFactoryBase + ?Sized > {
268+ pub executor :
269+ BoxFuture < ' static , Result < ( Arc < dyn ExportTargetExecutor > , Option < Arc < dyn QueryTarget > > ) > > ,
270+ pub setup_key : F :: Key ,
271+ pub desired_setup_state : F :: SetupState ,
272+ }
273+
275274pub trait StorageFactoryBase : ExportTargetFactory + Send + Sync + ' static {
276275 type Spec : DeserializeOwned + Send + Sync ;
277276 type Key : Debug + Clone + Serialize + DeserializeOwned + Eq + Hash + Send + Sync ;
@@ -287,11 +286,9 @@ pub trait StorageFactoryBase: ExportTargetFactory + Send + Sync + 'static {
287286 value_fields_schema : Vec < FieldSchema > ,
288287 storage_options : IndexOptions ,
289288 context : Arc < FlowInstanceContext > ,
290- ) -> Result < (
291- ( Self :: Key , Self :: SetupState ) ,
292- BoxFuture < ' static , Result < ( Arc < dyn ExportTargetExecutor > , Option < Arc < dyn QueryTarget > > ) > > ,
293- ) > ;
289+ ) -> Result < ExportTargetBuildOutput < Self > > ;
294290
291+ /// This is only called for non-user-setup targets.
295292 fn check_setup_status (
296293 & self ,
297294 key : Self :: Key ,
@@ -387,12 +384,9 @@ impl<T: StorageFactoryBase> ExportTargetFactory for T {
387384 value_fields_schema : Vec < FieldSchema > ,
388385 storage_options : IndexOptions ,
389386 context : Arc < FlowInstanceContext > ,
390- ) -> Result < (
391- ( serde_json:: Value , serde_json:: Value ) ,
392- BoxFuture < ' static , Result < ( Arc < dyn ExportTargetExecutor > , Option < Arc < dyn QueryTarget > > ) > > ,
393- ) > {
387+ ) -> Result < interface:: ExportTargetBuildOutput > {
394388 let spec: T :: Spec = serde_json:: from_value ( spec) ?;
395- let ( ( setup_key , setup_state ) , executors ) = StorageFactoryBase :: build (
389+ let build_output = StorageFactoryBase :: build (
396390 self ,
397391 name,
398392 spec,
@@ -401,13 +395,11 @@ impl<T: StorageFactoryBase> ExportTargetFactory for T {
401395 storage_options,
402396 context,
403397 ) ?;
404- Ok ( (
405- (
406- serde_json:: to_value ( setup_key) ?,
407- serde_json:: to_value ( setup_state) ?,
408- ) ,
409- executors,
410- ) )
398+ Ok ( interface:: ExportTargetBuildOutput {
399+ executor : build_output. executor ,
400+ setup_key : serde_json:: to_value ( build_output. setup_key ) ?,
401+ desired_setup_state : serde_json:: to_value ( build_output. desired_setup_state ) ?,
402+ } )
411403 }
412404
413405 fn check_setup_status (
0 commit comments