Files
foxhunt/fxt/examples/complete_client_example.rs
jgrusewski 2da5bafc0e refactor: rename tli→fxt, delete legacy scripts/RunPod/deploy artifacts
- Rename tli/ directory to fxt/, update package + binary name to "fxt"
- Replace all `use tli::` → `use fxt::` across 52 Rust files
- Update build.rs proto paths (tli/proto → fxt/proto) in 6 services
- Update Dockerfiles, CI workflows, deploy.sh for new paths
- Delete ~170 legacy shell scripts (kept 15 essential ones)
- Delete RunPod Python client (runpod/), tests (tests/runpod/)
- Delete foxhunt-deploy crate (RunPod-only deployment tool)
- Delete terraform/runpod/ (moved to Scaleway)
- Delete ML Python hyperopt scripts (replaced by Rust Argmin PSO)
- Delete .gitlab-ci.yml (using GitHub + Gitea)
- Remove foxhunt-deploy from workspace members

504 files changed, -74,355 lines of legacy code removed.
Workspace compiles clean (0 errors, 0 warnings).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 10:32:21 +01:00

122 lines
4.1 KiB
Rust

//! Complete TLI Client Example
//!
//! This example demonstrates how to use the TLI client infrastructure
//! to connect to both Trading Service and Backtesting Service.
#![allow(unused_crate_dependencies)]
use fxt::prelude::*;
use tokio::time::{sleep, Duration};
use tracing::{error, info, warn};
#[tokio::main]
async fn main() -> TliResult<()> {
// Initialize logging
tracing_subscriber::fmt::init();
info!("Starting TLI Complete Client Example");
// Create client suite with both services
let client_suite = TliClientBuilder::new()
.with_service_endpoint(
"trading_service".to_string(),
"http://localhost:50051".to_string(),
)
.with_service_endpoint(
"backtesting_service".to_string(),
"http://localhost:50053".to_string(),
)
.with_trading_config(TradingClientConfig {
endpoint: "http://localhost:50051".to_string(),
timeout_ms: 10_000,
})
.with_backtesting_config(BacktestingClientConfig {
endpoint: "http://localhost:50053".to_string(),
timeout_ms: 10_000,
})
.build()
.await?;
info!("Client suite created successfully");
// Demonstrate trading operations
if let Some(mut trading_client) = client_suite.trading_client {
info!("Connecting to trading service...");
match trading_client.connect().await {
Ok(_) => {
info!("Connected to trading service successfully");
info!("Connection status: {}", trading_client.is_connected());
// Note: Actual trading operations would require implementing
// the gRPC service methods. This example shows the client setup.
info!("Trading client is ready for operations");
},
Err(e) => {
error!("Failed to connect to trading service: {}", e);
},
}
// Cleanup
trading_client.shutdown().await;
info!("Trading client shut down");
} else {
warn!("Trading client not available");
}
// Demonstrate backtesting operations
if let Some(mut backtesting_client) = client_suite.backtesting_client {
info!("Connecting to backtesting service...");
match backtesting_client.connect().await {
Ok(_) => {
info!("Connected to backtesting service successfully");
info!("Connection status: {}", backtesting_client.is_connected());
// Note: Actual backtesting operations would require implementing
// the gRPC service methods. This example shows the client setup.
info!("Backtesting client is ready for operations");
},
Err(e) => {
error!("Failed to connect to backtesting service: {}", e);
},
}
// Cleanup
backtesting_client.shutdown().await;
info!("Backtesting client shut down");
} else {
warn!("Backtesting client not available");
}
// Demonstrate ML training operations
if let Some(mut ml_client) = client_suite.ml_training_client {
info!("Connecting to ML training service...");
match ml_client.connect().await {
Ok(_) => {
info!("Connected to ML training service successfully");
info!("Connection status: {}", ml_client.is_connected());
// Note: Actual ML training operations would require implementing
// the gRPC service methods. This example shows the client setup.
info!("ML training client is ready for operations");
},
Err(e) => {
error!("Failed to connect to ML training service: {}", e);
},
}
// Cleanup
ml_client.shutdown().await;
info!("ML training client shut down");
} else {
warn!("ML training client not available");
}
// Allow some time for graceful shutdown
sleep(Duration::from_secs(1)).await;
info!("Example completed successfully");
Ok(())
}