From b69de781b9bf25a06090bf2d1ea42b078dbfb2ae Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Thu, 23 Apr 2026 08:37:44 +0200 Subject: [PATCH] cleanup: delete sqlx_test placeholder and restore BrokerAdapter alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - common/sqlx_test.rs: the entire module was a single /* ... */ block behind a TODO because the identifier types (`OrderId`, `TradeId`, `Symbol`, `AccountId`, `OrderSide`) do not derive `sqlx::Type`. The file has been a dead placeholder behind `#[cfg(all(test, feature=\"database\"))]` for a long time; delete it and drop the `mod sqlx_test;` declaration. - data/brokers/mod.rs: re-enable the `pub type BrokerAdapter = Box;` alias — the trait is already implemented by `InteractiveBrokersAdapter` and re-exported from the module. Delete the commented-out `BrokerFactory::create_client` block: it referenced `ICMarketsClient`, which does not exist in this crate. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/common/src/lib.rs | 4 -- crates/common/src/sqlx_test.rs | 92 ---------------------------------- crates/data/src/brokers/mod.rs | 83 ++---------------------------- 3 files changed, 5 insertions(+), 174 deletions(-) delete mode 100644 crates/common/src/sqlx_test.rs diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 6e018328d..1b774f69c 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -130,7 +130,3 @@ pub use crate::observability::{ // Test utilities module (available for all tests) #[cfg(test)] pub mod test_utils; - -// Test module for database features -#[cfg(all(test, feature = "database"))] -mod sqlx_test; diff --git a/crates/common/src/sqlx_test.rs b/crates/common/src/sqlx_test.rs deleted file mode 100644 index 03aa642ad..000000000 --- a/crates/common/src/sqlx_test.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! SQLx trait implementation tests for identifier types -//! Temporarily disabled due to incomplete SQLx trait implementations - -// TODO: Re-enable once SQLx traits are properly implemented for all types -/* -#[cfg(all(test, feature = "database"))] -mod tests { - use crate::types::*; - use sqlx::{Postgres, TypeInfo}; - - /// Test OrderId SQLx serialization/deserialization - #[test] - fn test_order_id_sqlx() { - let order_id = OrderId::new(); - - // Test that OrderId can be used in SQLx queries (compile-time check) - let type_info = >::type_info(); - let _: bool = sqlx::types::Type::::compatible(&type_info); - } - - /// Test TradeId SQLx serialization/deserialization - #[test] - fn test_trade_id_sqlx() -> Result<(), Box> { - let trade_id = TradeId::new("TRADE-001")?; - - // Test that TradeId can be used in SQLx queries (compile-time check) - let type_info = >::type_info(); - let _: bool = sqlx::types::Type::::compatible(&type_info); - Ok(()) - } - - /// Test Symbol SQLx serialization/deserialization - #[test] - fn test_symbol_sqlx() -> Result<(), Box> { - let symbol = Symbol::new_validated("AAPL".to_owned())?; - - // Test that Symbol can be used in SQLx queries (compile-time check) - let type_info = >::type_info(); - let _: bool = sqlx::types::Type::::compatible(&type_info); - Ok(()) - } - - /// Test AccountId SQLx serialization/deserialization - #[test] - fn test_account_id_sqlx() -> Result<(), Box> { - let account_id = AccountId::new("ACC-001")?; - - // Test that AccountId can be used in SQLx queries (compile-time check) - let type_info = >::type_info(); - let _: bool = sqlx::types::Type::::compatible(&type_info); - Ok(()) - } - - /// Test OrderSide SQLx serialization/deserialization - #[test] - fn test_order_side_sqlx() { - let buy_side = OrderSide::Buy; - let sell_side = OrderSide::Sell; - - // Test that OrderSide can be used in SQLx queries (compile-time check) - let type_info = >::type_info(); - let _: bool = sqlx::types::Type::::compatible(&type_info); - } - - /// Test that transparent newtypes work with underlying PostgreSQL types - #[test] - fn test_transparent_type_mapping() { - // OrderId should map to BIGINT (i64/u64) - assert_eq!( - >::type_info().name(), - "BIGINT" - ); - - // String-based types should map to TEXT - assert_eq!( - >::type_info().name(), - "TEXT" - ); - - assert_eq!( - >::type_info().name(), - "TEXT" - ); - - // OrderSide should map to TEXT - assert_eq!( - >::type_info().name(), - "TEXT" - ); - } -} -*/ diff --git a/crates/data/src/brokers/mod.rs b/crates/data/src/brokers/mod.rs index e38326afc..a0d84764a 100644 --- a/crates/data/src/brokers/mod.rs +++ b/crates/data/src/brokers/mod.rs @@ -124,13 +124,11 @@ pub use interactive_brokers::{IBConfig, InteractiveBrokersAdapter}; /// Re-export common broker client trait pub use common::BrokerClient; -// Create alias for BrokerAdapter (used in examples) -// TODO: Re-enable when BrokerClient trait is implemented -// /// Type alias for boxed broker client trait objects -// /// -// /// Provides a convenient way to work with different broker implementations -// /// through a common interface without knowing the specific type at compile time. -// pub type BrokerAdapter = Box; +/// Type alias for boxed broker client trait objects. +/// +/// Provides a convenient way to work with different broker implementations +/// through a common interface without knowing the specific type at compile time. +pub type BrokerAdapter = Box; /// Enumeration of supported broker types and their protocols. /// @@ -364,75 +362,4 @@ impl BrokerFactory { } } - // TODO: Uncomment when BrokerClient trait is restored - /* - /// Create a broker client based on configuration. - /// - /// Instantiates the appropriate broker client implementation based on - /// the broker type and configuration provided. Validates configuration - /// before attempting to create the client. - /// - /// # Parameters - /// - /// * `broker_type` - Type of broker client to create - /// * `config` - JSON configuration object with broker-specific settings - /// - /// # Returns - /// - /// Boxed broker client implementing the `BrokerClient` trait. - /// - /// # Errors - /// - /// Returns `DataError` if: - /// - Configuration is invalid or missing required fields - /// - Broker type is not yet implemented - /// - Client initialization fails - /// - /// # Examples - /// - /// ```rust - /// use data::brokers::{BrokerFactory, BrokerType}; - /// use serde_json::json; - /// - /// let config = json!({ - /// "host": "127.0.0.1", - /// "port": 7497, - /// "client_id": 1 - /// }); - /// - /// let client = BrokerFactory::create_client( - /// BrokerType::InteractiveBrokers, - /// config - /// ).await?; - /// ``` - pub async fn create_client( - broker_type: BrokerType, - config: serde_json::Value - ) -> crate::Result> { - // Validate configuration first - Self::validate_config(&broker_type, &config) - .map_err(|e| crate::DataError::configuration(&e))?; - - match broker_type { - BrokerType::ICMarkets => { - let icmarkets_config: ICMarketsConfig = serde_json::from_value(config) - .map_err(|e| crate::DataError::configuration(&format!("Invalid ICMarkets config: {}", e)))?; - let client = ICMarketsClient::new(icmarkets_config); - Ok(Box::new(client)) - } - BrokerType::InteractiveBrokers => { - let ib_config: IBConfig = serde_json::from_value(config) - .map_err(|e| crate::DataError::configuration(&format!("Invalid IB config: {}", e)))?; - let client = InteractiveBrokersAdapter::new(ib_config); - Ok(Box::new(client)) - } - BrokerType::Alpaca => { - Err(crate::DataError::configuration("Alpaca broker not yet implemented")) - } - BrokerType::Mock => { - Err(crate::DataError::configuration("Mock broker not yet implemented")) - } - } - } - */ }