Skip to content

Commit 9db2a9c

Browse files
authored
refactor: rename a few target trait types for clarify (#885)
1 parent d3ed905 commit 9db2a9c

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

src/ops/factory_bases.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl<T: SimpleFunctionFactoryBase> SimpleFunctionFactory for T {
352352

353353
pub struct TypedExportDataCollectionBuildOutput<F: TargetFactoryBase + ?Sized> {
354354
pub export_context: BoxFuture<'static, Result<Arc<F::ExportContext>>>,
355-
pub setup_key: F::Key,
355+
pub setup_key: F::SetupKey,
356356
pub desired_setup_state: F::SetupState,
357357
}
358358
pub struct TypedExportDataCollectionSpec<F: TargetFactoryBase + ?Sized> {
@@ -364,17 +364,19 @@ pub struct TypedExportDataCollectionSpec<F: TargetFactoryBase + ?Sized> {
364364
}
365365

366366
pub struct TypedResourceSetupChangeItem<'a, F: TargetFactoryBase + ?Sized> {
367-
pub key: F::Key,
367+
pub key: F::SetupKey,
368368
pub setup_change: &'a F::SetupChange,
369369
}
370370

371371
#[async_trait]
372372
pub trait TargetFactoryBase: TargetFactory + Send + Sync + 'static {
373373
type Spec: DeserializeOwned + Send + Sync;
374374
type DeclarationSpec: DeserializeOwned + Send + Sync;
375-
type Key: Debug + Clone + Serialize + DeserializeOwned + Eq + Hash + Send + Sync;
375+
376+
type SetupKey: Debug + Clone + Serialize + DeserializeOwned + Eq + Hash + Send + Sync;
376377
type SetupState: Debug + Clone + Serialize + DeserializeOwned + Send + Sync;
377378
type SetupChange: ResourceSetupChange;
379+
378380
type ExportContext: Send + Sync + 'static;
379381

380382
fn name(&self) -> &str;
@@ -386,20 +388,20 @@ pub trait TargetFactoryBase: TargetFactory + Send + Sync + 'static {
386388
context: Arc<FlowInstanceContext>,
387389
) -> Result<(
388390
Vec<TypedExportDataCollectionBuildOutput<Self>>,
389-
Vec<(Self::Key, Self::SetupState)>,
391+
Vec<(Self::SetupKey, Self::SetupState)>,
390392
)>;
391393

392394
/// Deserialize the setup key from a JSON value.
393395
/// You can override this method to provide a custom deserialization logic, e.g. to perform backward compatible deserialization.
394-
fn deserialize_setup_key(key: serde_json::Value) -> Result<Self::Key> {
396+
fn deserialize_setup_key(key: serde_json::Value) -> Result<Self::SetupKey> {
395397
Ok(serde_json::from_value(key)?)
396398
}
397399

398400
/// Will not be called if it's setup by user.
399401
/// It returns an error if the target only supports setup by user.
400402
async fn diff_setup_states(
401403
&self,
402-
key: Self::Key,
404+
key: Self::SetupKey,
403405
desired_state: Option<Self::SetupState>,
404406
existing_states: setup::CombinedState<Self::SetupState>,
405407
flow_instance_ctx: Arc<FlowInstanceContext>,
@@ -411,7 +413,7 @@ pub trait TargetFactoryBase: TargetFactory + Send + Sync + 'static {
411413
existing_state: &Self::SetupState,
412414
) -> Result<SetupStateCompatibility>;
413415

414-
fn describe_resource(&self, key: &Self::Key) -> Result<String>;
416+
fn describe_resource(&self, key: &Self::SetupKey) -> Result<String>;
415417

416418
fn extract_additional_key(
417419
&self,
@@ -504,7 +506,7 @@ impl<T: TargetFactoryBase> TargetFactory for T {
504506
existing_states: setup::CombinedState<serde_json::Value>,
505507
flow_instance_ctx: Arc<FlowInstanceContext>,
506508
) -> Result<Box<dyn setup::ResourceSetupChange>> {
507-
let key: T::Key = Self::deserialize_setup_key(key.clone())?;
509+
let key: T::SetupKey = Self::deserialize_setup_key(key.clone())?;
508510
let desired_state: Option<T::SetupState> = desired_state
509511
.map(|v| serde_json::from_value(v.clone()))
510512
.transpose()?;
@@ -521,12 +523,12 @@ impl<T: TargetFactoryBase> TargetFactory for T {
521523
}
522524

523525
fn describe_resource(&self, key: &serde_json::Value) -> Result<String> {
524-
let key: T::Key = Self::deserialize_setup_key(key.clone())?;
526+
let key: T::SetupKey = Self::deserialize_setup_key(key.clone())?;
525527
TargetFactoryBase::describe_resource(self, &key)
526528
}
527529

528530
fn normalize_setup_key(&self, key: &serde_json::Value) -> Result<serde_json::Value> {
529-
let key: T::Key = Self::deserialize_setup_key(key.clone())?;
531+
let key: T::SetupKey = Self::deserialize_setup_key(key.clone())?;
530532
Ok(serde_json::to_value(key)?)
531533
}
532534

src/ops/targets/kuzu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ impl TargetFactoryBase for Factory {
745745
type SetupState = SetupState;
746746
type SetupChange = GraphElementDataSetupChange;
747747

748-
type Key = KuzuGraphElement;
748+
type SetupKey = KuzuGraphElement;
749749
type ExportContext = ExportContext;
750750

751751
fn name(&self) -> &str {

src/ops/targets/neo4j.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ impl TargetFactoryBase for Factory {
926926
GraphElementDataSetupChange,
927927
components::SetupChange<SetupComponentOperator>,
928928
);
929-
type Key = Neo4jGraphElement;
929+
type SetupKey = Neo4jGraphElement;
930930
type ExportContext = ExportContext;
931931

932932
fn name(&self) -> &str {

src/ops/targets/postgres.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl TargetFactoryBase for Factory {
656656
type DeclarationSpec = ();
657657
type SetupState = SetupState;
658658
type SetupChange = SetupChange;
659-
type Key = TableId;
659+
type SetupKey = TableId;
660660
type ExportContext = ExportContext;
661661

662662
fn name(&self) -> &str {

src/ops/targets/qdrant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl TargetFactoryBase for Factory {
368368
type DeclarationSpec = ();
369369
type SetupState = SetupState;
370370
type SetupChange = SetupChange;
371-
type Key = CollectionKey;
371+
type SetupKey = CollectionKey;
372372
type ExportContext = ExportContext;
373373

374374
fn name(&self) -> &str {

0 commit comments

Comments
 (0)