Skip to main content

dataplane_sdk/core/db/
data_flow.rs

1//  Copyright (c) 2026 Metaform Systems, Inc
2//
3//  This program and the accompanying materials are made available under the
4//  terms of the Apache License, Version 2.0 which is available at
5//  https://www.apache.org/licenses/LICENSE-2.0
6//
7//    SPDX-License-Identifier: Apache-2.0
8//
9//    Contributors:
10//         Metaform Systems, Inc. - initial API and implementation
11//
12
13use crate::core::{error::DbResult, model::data_flow::DataFlow};
14pub mod memory;
15
16#[cfg(test)]
17use crate::core::db::tx::MockTransaction;
18
19#[async_trait::async_trait]
20#[cfg_attr(test, mockall::automock(type Transaction = MockTransaction;))]
21pub trait DataFlowRepo: Send + Sync {
22    type Transaction;
23
24    async fn create(&self, tx: &mut Self::Transaction, flow: &DataFlow) -> DbResult<()>;
25
26    async fn fetch_by_id(
27        &self,
28        tx: &mut Self::Transaction,
29        flow_id: &str,
30    ) -> DbResult<Option<DataFlow>>;
31
32    async fn update(&self, tx: &mut Self::Transaction, flow: &DataFlow) -> DbResult<()>;
33
34    async fn delete(&self, tx: &mut Self::Transaction, flow_id: &str) -> DbResult<()>;
35}