Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1441 from Cargill/lbradley-add-batch-tracking-to-…
Browse files Browse the repository at this point in the history
…store-factory

Add batch tracking to the store factory
  • Loading branch information
Lee Bradley committed Jun 8, 2022
2 parents 9aaaf56 + ffd246c commit b736501
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sdk/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use std::str::FromStr;
#[cfg(feature = "diesel")]
use diesel::r2d2::{ConnectionManager, Pool};

#[cfg(feature = "batch-tracking")]
use crate::batch_tracking::store::BatchTrackingStore;
#[cfg(feature = "batch-store")]
use crate::batches::store::BatchStore;
use crate::commits::store::CommitStore;
Expand Down Expand Up @@ -62,6 +64,8 @@ pub trait StoreFactory {
fn get_batch_store<'a>(&'a self) -> Box<dyn BatchStore + 'a>;
#[cfg(feature = "purchase-order")]
fn get_grid_purchase_order_store<'a>(&'a self) -> Box<dyn PurchaseOrderStore + 'a>;
#[cfg(feature = "batch-tracking")]
fn get_batch_tracking_store<'a>(&'a self) -> Box<dyn BatchTrackingStore + 'a>;
}

pub trait TransactionalStoreFactory: StoreFactory + Send + Sync {
Expand Down
15 changes: 15 additions & 0 deletions sdk/src/store/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ use diesel::{
Connection,
};

#[cfg(feature = "batch-tracking")]
use crate::batch_tracking::store::{
diesel::{DieselBatchTrackingStore, DieselConnectionBatchTrackingStore},
BatchTrackingStore,
};
#[cfg(feature = "batch-store")]
use crate::batches::store::{BatchStore, DieselBatchStore, DieselConnectionBatchStore};
use crate::commits::store::{CommitStore, DieselCommitStore, DieselConnectionCommitStore};
Expand Down Expand Up @@ -93,6 +98,11 @@ impl StoreFactory for PgStoreFactory {
fn get_grid_purchase_order_store<'a>(&'a self) -> Box<dyn PurchaseOrderStore + 'a> {
Box::new(DieselPurchaseOrderStore::new(self.pool.clone()))
}

#[cfg(feature = "batch-tracking")]
fn get_batch_tracking_store<'a>(&'a self) -> Box<dyn BatchTrackingStore + 'a> {
Box::new(DieselBatchTrackingStore::new(self.pool.clone()))
}
}

impl TransactionalStoreFactory for PgStoreFactory {
Expand Down Expand Up @@ -165,6 +175,11 @@ impl StoreFactory for InContextPgStoreFactory {
fn get_grid_purchase_order_store<'a>(&'a self) -> Box<dyn PurchaseOrderStore + 'a> {
Box::new(DieselConnectionPurchaseOrderStore::new(&*self.conn))
}

#[cfg(feature = "batch-tracking")]
fn get_batch_tracking_store<'a>(&'a self) -> Box<dyn BatchTrackingStore + 'a> {
Box::new(DieselConnectionBatchTrackingStore::new(&*self.conn))
}
}

impl<'a> InContextStoreFactory<'a> for InContextPgStoreFactory {
Expand Down
15 changes: 15 additions & 0 deletions sdk/src/store/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ use diesel::{
Connection,
};

#[cfg(feature = "batch-tracking")]
use crate::batch_tracking::store::{
diesel::{DieselBatchTrackingStore, DieselConnectionBatchTrackingStore},
BatchTrackingStore,
};
#[cfg(feature = "batch-store")]
use crate::batches::store::{BatchStore, DieselBatchStore, DieselConnectionBatchStore};
use crate::commits::store::{CommitStore, DieselCommitStore, DieselConnectionCommitStore};
Expand Down Expand Up @@ -93,6 +98,11 @@ impl StoreFactory for SqliteStoreFactory {
fn get_grid_purchase_order_store<'a>(&'a self) -> Box<dyn PurchaseOrderStore + 'a> {
Box::new(DieselPurchaseOrderStore::new(self.pool.clone()))
}

#[cfg(feature = "batch-tracking")]
fn get_batch_tracking_store<'a>(&'a self) -> Box<dyn BatchTrackingStore + 'a> {
Box::new(DieselBatchTrackingStore::new(self.pool.clone()))
}
}

impl TransactionalStoreFactory for SqliteStoreFactory {
Expand Down Expand Up @@ -165,6 +175,11 @@ impl StoreFactory for InContextSqliteStoreFactory {
fn get_grid_purchase_order_store<'a>(&'a self) -> Box<dyn PurchaseOrderStore + 'a> {
Box::new(DieselConnectionPurchaseOrderStore::new(&*self.conn))
}

#[cfg(feature = "batch-tracking")]
fn get_batch_tracking_store<'a>(&'a self) -> Box<dyn BatchTrackingStore + 'a> {
Box::new(DieselConnectionBatchTrackingStore::new(&*self.conn))
}
}

impl<'a> InContextStoreFactory<'a> for InContextSqliteStoreFactory {
Expand Down

0 comments on commit b736501

Please sign in to comment.