diff --git a/src/ops/storages/neo4j.rs b/src/ops/storages/neo4j.rs index 0311e9c64..cf5f3cc69 100644 --- a/src/ops/storages/neo4j.rs +++ b/src/ops/storages/neo4j.rs @@ -696,6 +696,7 @@ impl components::SetupOperator for SetupComponentOperator { type Key = ComponentKey; type State = ComponentState; type SetupState = SetupState; + type Context = (); fn describe_key(&self, key: &Self::Key) -> String { format!("{} {}", key.kind.describe(), key.name) @@ -724,7 +725,7 @@ impl components::SetupOperator for SetupComponentOperator { current == desired } - async fn create(&self, state: &ComponentState) -> Result<()> { + async fn create(&self, state: &ComponentState, _context: &Self::Context) -> Result<()> { let graph = self.graph_pool.get_graph(&self.conn_spec).await?; let key = state.key(); let qualifier = CORE_ELEMENT_MATCHER_VAR; @@ -762,7 +763,7 @@ impl components::SetupOperator for SetupComponentOperator { Ok(graph.run(query).await?) } - async fn delete(&self, key: &ComponentKey) -> Result<()> { + async fn delete(&self, key: &ComponentKey, _context: &Self::Context) -> Result<()> { let graph = self.graph_pool.get_graph(&self.conn_spec).await?; let query = neo4rs::query(&format!( "DROP {kind} {name} IF EXISTS", @@ -1131,7 +1132,7 @@ impl StorageFactoryBase for Factory { } } - apply_component_changes(components).await?; + apply_component_changes(components, &()).await?; Ok(()) } } diff --git a/src/setup/components.rs b/src/setup/components.rs index 415f616e3..738bc298a 100644 --- a/src/setup/components.rs +++ b/src/setup/components.rs @@ -11,6 +11,7 @@ pub trait SetupOperator: 'static + Send + Sync { type Key: Debug + Hash + Eq + Clone + Send + Sync; type State: State; type SetupState: Send + Sync + IntoIterator; + type Context: Sync; fn describe_key(&self, key: &Self::Key) -> String; @@ -18,13 +19,13 @@ pub trait SetupOperator: 'static + Send + Sync { fn is_up_to_date(&self, current: &Self::State, desired: &Self::State) -> bool; - async fn create(&self, state: &Self::State) -> Result<()>; + async fn create(&self, state: &Self::State, context: &Self::Context) -> Result<()>; - async fn delete(&self, key: &Self::Key) -> Result<()>; + async fn delete(&self, key: &Self::Key, context: &Self::Context) -> Result<()>; - async fn update(&self, state: &Self::State) -> Result<()> { - self.delete(&state.key()).await?; - self.create(state).await + async fn update(&self, state: &Self::State, context: &Self::Context) -> Result<()> { + self.delete(&state.key(), context).await?; + self.create(state, context).await } } @@ -150,11 +151,12 @@ impl ResourceSetupStatus for SetupStatus { pub async fn apply_component_changes( changes: Vec<&SetupStatus>, + context: &D::Context, ) -> Result<()> { // First delete components that need to be removed for change in changes.iter() { for key in &change.keys_to_delete { - change.desc.delete(key).await?; + change.desc.delete(key, context).await?; } } @@ -162,9 +164,9 @@ pub async fn apply_component_changes( for change in changes.iter() { for state in &change.states_to_upsert { if state.already_exists { - change.desc.update(&state.state).await?; + change.desc.update(&state.state, context).await?; } else { - change.desc.create(&state.state).await?; + change.desc.create(&state.state, context).await?; } } }