Skip to content

Commit 78b0153

Browse files
committed
improve: remove obsolete code
1 parent 0b8fe55 commit 78b0153

File tree

15 files changed

+9
-1250
lines changed

15 files changed

+9
-1250
lines changed

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ members = [
55
"crates/inferadb-control-config",
66
"crates/inferadb-control-const",
77
"crates/inferadb-control-core",
8-
9-
"crates/inferadb-control-engine-client",
108
"crates/inferadb-control-storage",
119
"crates/inferadb-control-test-fixtures",
1210
"crates/inferadb-control-types",

crates/inferadb-control-api/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ version.workspace = true
1313
# Workspace crates
1414
inferadb-control-const = { path = "../inferadb-control-const" }
1515
inferadb-control-core = { path = "../inferadb-control-core" }
16-
inferadb-control-engine-client = { path = "../inferadb-control-engine-client" }
1716
inferadb-control-storage = { path = "../inferadb-control-storage" }
1817
inferadb-control-types = { path = "../inferadb-control-types" }
1918
inferadb-storage = { path = "../../../common/crates/inferadb-storage" }

crates/inferadb-control-api/src/handlers/auth.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use inferadb_control_core::{
1212
IdGenerator, RepositoryContext, UserPasswordResetToken, error::Error as CoreError,
1313
hash_password, verify_password,
1414
};
15-
use inferadb_control_engine_client::EngineClient;
1615
use inferadb_control_storage::Backend;
1716
use inferadb_control_types::{
1817
dto::{
@@ -33,7 +32,6 @@ use time;
3332
pub struct AppState {
3433
pub storage: Arc<Backend>,
3534
pub config: Arc<inferadb_control_core::ControlConfig>,
36-
pub engine_client: Arc<EngineClient>,
3735
pub worker_id: u16,
3836
pub start_time: std::time::SystemTime,
3937
pub leader: Option<Arc<inferadb_control_core::LeaderElection<Backend>>>,
@@ -45,7 +43,6 @@ pub struct AppState {
4543
pub struct AppStateBuilder {
4644
storage: Arc<Backend>,
4745
config: Arc<inferadb_control_core::ControlConfig>,
48-
engine_client: Arc<EngineClient>,
4946
worker_id: u16,
5047
leader: Option<Arc<inferadb_control_core::LeaderElection<Backend>>>,
5148
email_service: Option<Arc<inferadb_control_core::EmailService>>,
@@ -57,13 +54,11 @@ impl AppStateBuilder {
5754
pub fn new(
5855
storage: Arc<Backend>,
5956
config: Arc<inferadb_control_core::ControlConfig>,
60-
engine_client: Arc<EngineClient>,
6157
worker_id: u16,
6258
) -> Self {
6359
Self {
6460
storage,
6561
config,
66-
engine_client,
6762
worker_id,
6863
leader: None,
6964
email_service: None,
@@ -100,7 +95,6 @@ impl AppStateBuilder {
10095
AppState {
10196
storage: self.storage,
10297
config: self.config,
103-
engine_client: self.engine_client,
10498
worker_id: self.worker_id,
10599
start_time: std::time::SystemTime::now(),
106100
leader: self.leader,
@@ -116,17 +110,16 @@ impl AppState {
116110
/// # Example
117111
///
118112
/// ```ignore
119-
/// let state = AppState::builder(storage, config, engine_client, worker_id)
113+
/// let state = AppState::builder(storage, config, worker_id)
120114
/// .email_service(email_service)
121115
/// .build();
122116
/// ```
123117
pub fn builder(
124118
storage: Arc<Backend>,
125119
config: Arc<inferadb_control_core::ControlConfig>,
126-
engine_client: Arc<EngineClient>,
127120
worker_id: u16,
128121
) -> AppStateBuilder {
129-
AppStateBuilder::new(storage, config, engine_client, worker_id)
122+
AppStateBuilder::new(storage, config, worker_id)
130123
}
131124

132125
/// Create AppState for testing with default configuration
@@ -141,7 +134,6 @@ impl AppState {
141134
config.key_file = Some("/tmp/test-master.key".to_string());
142135
config.webauthn.party = "localhost".to_string();
143136
config.webauthn.origin = "http://localhost:3000".to_string();
144-
let engine_client = EngineClient::new("http://localhost".to_string(), 8080).unwrap();
145137

146138
// Create mock email service for testing
147139
let email_sender = Box::new(inferadb_control_core::MockEmailSender::new());
@@ -150,7 +142,6 @@ impl AppState {
150142
Self {
151143
storage,
152144
config: Arc::new(config),
153-
engine_client: Arc::new(engine_client),
154145
worker_id: 0,
155146
start_time: std::time::SystemTime::now(),
156147
leader: None,

crates/inferadb-control-api/src/handlers/vaults.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,11 @@ pub async fn create_vault(
110110
org_ctx.member.user_id,
111111
)?;
112112

113-
// Save to repository
114-
repos.vault.create(vault.clone()).await?;
113+
// Mark as synced immediately - Ledger is the source of truth
114+
vault.mark_synced();
115115

116-
// Attempt to sync with engine
117-
match state.engine_client.create_vault(vault_id, org_ctx.organization_id).await {
118-
Ok(()) => {
119-
// Mark as synced
120-
vault.mark_synced();
121-
repos.vault.update(vault.clone()).await?;
122-
},
123-
Err(e) => {
124-
// Mark as failed
125-
let error_message: String = e.to_string();
126-
vault.mark_sync_failed(error_message);
127-
repos.vault.update(vault.clone()).await?;
128-
},
129-
}
116+
// Save to repository (writes to Ledger)
117+
repos.vault.create(vault.clone()).await?;
130118

131119
// Auto-grant creator ADMIN role
132120
let grant_id = IdGenerator::next_id();
@@ -352,11 +340,7 @@ pub async fn delete_vault(
352340
repos.vault_team_grant.delete(grant.id).await?;
353341
}
354342

355-
// Attempt to delete from engine
356-
// Note: Even if this fails, we soft-delete locally
357-
let _ = state.engine_client.delete_vault(vault_id).await;
358-
359-
// Soft delete
343+
// Soft delete (Ledger is the source of truth)
360344
vault.mark_deleted();
361345
repos.vault.update(vault).await?;
362346

crates/inferadb-control-api/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use std::sync::Arc;
66

77
use inferadb_control_core::{ControlConfig, startup};
8-
use inferadb_control_engine_client::EngineClient;
98
use inferadb_control_storage::Backend;
109
use tracing::info;
1110

@@ -69,13 +68,11 @@ pub struct ServicesConfig {
6968
pub async fn serve(
7069
storage: Arc<Backend>,
7170
config: Arc<ControlConfig>,
72-
engine_client: Arc<EngineClient>,
7371
worker_id: u16,
7472
services: ServicesConfig,
7573
) -> anyhow::Result<()> {
7674
// Create AppState with services using the builder pattern
77-
let mut builder =
78-
AppState::builder(storage.clone(), config.clone(), engine_client.clone(), worker_id);
75+
let mut builder = AppState::builder(storage.clone(), config.clone(), worker_id);
7976

8077
if let Some(leader) = services.leader {
8178
builder = builder.leader(leader);

crates/inferadb-control-config/src/lib.rs

Lines changed: 1 addition & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub mod refresh;
3232

3333
use std::path::Path;
3434

35-
// Import discovery config types (used in ControlConfig struct)
36-
use inferadb_control_types::DiscoveryConfig;
3735
use inferadb_control_types::error::{Error, Result};
3836
pub use refresh::ConfigRefresher;
3937
use serde::{Deserialize, Serialize};
@@ -109,12 +107,8 @@ pub struct ControlConfig {
109107
#[serde(default)]
110108
pub limits: LimitsConfig,
111109
#[serde(default)]
112-
pub mesh: MeshConfig,
113-
#[serde(default)]
114110
pub webhook: WebhookConfig,
115111
#[serde(default)]
116-
pub discovery: DiscoveryConfig,
117-
#[serde(default)]
118112
pub frontend: FrontendConfig,
119113
}
120114

@@ -130,11 +124,6 @@ pub struct ListenConfig {
130124
/// Format: "host:port" (e.g., "127.0.0.1:9091")
131125
#[serde(default = "default_grpc")]
132126
pub grpc: String,
133-
134-
/// Service mesh / inter-service communication address (engine-to-control, JWKS endpoint)
135-
/// Format: "host:port" (e.g., "0.0.0.0:9092")
136-
#[serde(default = "default_mesh")]
137-
pub mesh: String,
138127
}
139128

140129
/// WebAuthn configuration for passkey authentication
@@ -231,35 +220,6 @@ impl Default for FrontendConfig {
231220
}
232221
}
233222

234-
/// Service mesh configuration for engine communication
235-
///
236-
/// This configuration controls how control discovers and connects to
237-
/// engine (policy service) instances. Both gRPC and HTTP internal endpoints are
238-
/// derived from the same base URL with different ports.
239-
#[derive(Debug, Clone, Serialize, Deserialize)]
240-
pub struct MeshConfig {
241-
/// gRPC port for engine communication
242-
/// Default: 8081
243-
#[serde(default = "default_mesh_grpc")]
244-
pub grpc: u16,
245-
246-
/// Mesh port for internal communication (webhooks/JWKS)
247-
/// Default: 8082
248-
#[serde(default = "default_mesh_port")]
249-
pub port: u16,
250-
251-
/// Base URL (without port, used for discovery or direct connection)
252-
/// e.g., "http://inferadb-engine.inferadb" for K8s or "http://localhost" for dev
253-
#[serde(default = "default_mesh_url")]
254-
pub url: String,
255-
}
256-
257-
impl Default for MeshConfig {
258-
fn default() -> Self {
259-
Self { grpc: default_mesh_grpc(), port: default_mesh_port(), url: default_mesh_url() }
260-
}
261-
}
262-
263223
/// Webhook configuration for cache invalidation
264224
#[derive(Debug, Clone, Serialize, Deserialize)]
265225
pub struct WebhookConfig {
@@ -308,10 +268,6 @@ fn default_grpc() -> String {
308268
"127.0.0.1:9091".to_string()
309269
}
310270

311-
fn default_mesh() -> String {
312-
"0.0.0.0:9092".to_string() // Control internal/mesh server port
313-
}
314-
315271
fn default_threads() -> usize {
316272
num_cpus::get()
317273
}
@@ -348,18 +304,6 @@ fn default_password_reset_tokens_per_hour() -> u32 {
348304
3
349305
}
350306

351-
fn default_mesh_grpc() -> u16 {
352-
8081 // Engine's public gRPC port
353-
}
354-
355-
fn default_mesh_port() -> u16 {
356-
8082 // Engine's mesh/internal API port
357-
}
358-
359-
fn default_mesh_url() -> String {
360-
"http://localhost".to_string() // Default for development
361-
}
362-
363307
fn default_frontend_url() -> String {
364308
"http://localhost:3000".to_string()
365309
}
@@ -383,11 +327,7 @@ impl Default for ControlConfig {
383327
logging: default_logging(),
384328
storage: default_storage(),
385329
ledger: LedgerConfig::default(),
386-
listen: ListenConfig {
387-
http: default_http(),
388-
grpc: default_grpc(),
389-
mesh: default_mesh(),
390-
},
330+
listen: ListenConfig { http: default_http(), grpc: default_grpc() },
391331
webauthn: WebAuthnConfig::default(),
392332
key_file: default_key_file(),
393333
email: EmailConfig {
@@ -405,36 +345,14 @@ impl Default for ControlConfig {
405345
email_verification_tokens_per_hour: default_email_verification_tokens_per_hour(),
406346
password_reset_tokens_per_hour: default_password_reset_tokens_per_hour(),
407347
},
408-
mesh: MeshConfig::default(),
409348
pem: None,
410349
webhook: WebhookConfig::default(),
411-
discovery: DiscoveryConfig::default(),
412350
frontend: FrontendConfig::default(),
413351
}
414352
}
415353
}
416354

417355
impl ControlConfig {
418-
/// Get the effective gRPC URL for the engine service
419-
///
420-
/// Combines `mesh.url` with `mesh.grpc`
421-
/// to produce the full gRPC endpoint URL.
422-
///
423-
/// Example: "http://localhost" + 8081 → "http://localhost:8081"
424-
pub fn effective_grpc_url(&self) -> String {
425-
format!("{}:{}", self.mesh.url, self.mesh.grpc)
426-
}
427-
428-
/// Get the effective mesh URL for the engine service
429-
///
430-
/// Combines `mesh.url` with `mesh.port`
431-
/// to produce the full mesh/internal API endpoint URL.
432-
///
433-
/// Example: "http://localhost" + 8082 → "http://localhost:8082"
434-
pub fn effective_mesh_url(&self) -> String {
435-
format!("{}:{}", self.mesh.url, self.mesh.port)
436-
}
437-
438356
/// Load configuration with layered precedence: defaults → file → env vars
439357
///
440358
/// This function implements a proper configuration hierarchy:
@@ -517,9 +435,6 @@ impl ControlConfig {
517435
self.listen.grpc.parse::<std::net::SocketAddr>().map_err(|e| {
518436
Error::Config(format!("listen.grpc '{}' is not valid: {}", self.listen.grpc, e))
519437
})?;
520-
self.listen.mesh.parse::<std::net::SocketAddr>().map_err(|e| {
521-
Error::Config(format!("listen.mesh '{}' is not valid: {}", self.listen.mesh, e))
522-
})?;
523438

524439
// Validate storage backend
525440
match self.storage.as_str() {
@@ -605,14 +520,6 @@ impl ControlConfig {
605520
));
606521
}
607522

608-
// Validate mesh.url format
609-
if !self.mesh.url.starts_with("http://") && !self.mesh.url.starts_with("https://") {
610-
return Err(Error::Config("mesh.url must start with http:// or https://".to_string()));
611-
}
612-
if self.mesh.url.ends_with('/') {
613-
return Err(Error::Config("mesh.url must not end with trailing slash".to_string()));
614-
}
615-
616523
Ok(())
617524
}
618525

@@ -658,7 +565,6 @@ mod tests {
658565
fn test_config_defaults() {
659566
assert_eq!(default_http(), "127.0.0.1:9090");
660567
assert_eq!(default_grpc(), "127.0.0.1:9091");
661-
assert_eq!(default_mesh(), "0.0.0.0:9092");
662568
assert_eq!(default_storage(), "ledger"); // Ledger is now the default
663569
assert_eq!(default_webauthn_party(), "localhost");
664570
assert_eq!(default_webauthn_origin(), "http://localhost:3000");
@@ -695,18 +601,4 @@ mod tests {
695601
config.ledger.namespace_id = Some(1);
696602
assert!(config.validate().is_ok());
697603
}
698-
699-
#[test]
700-
fn test_effective_urls() {
701-
let config = ControlConfig::default();
702-
assert_eq!(config.effective_grpc_url(), "http://localhost:8081");
703-
assert_eq!(config.effective_mesh_url(), "http://localhost:8082");
704-
705-
let mut config = ControlConfig::default();
706-
config.mesh.url = "http://inferadb-engine.inferadb".to_string();
707-
config.mesh.grpc = 9000;
708-
config.mesh.port = 9191;
709-
assert_eq!(config.effective_grpc_url(), "http://inferadb-engine.inferadb:9000");
710-
assert_eq!(config.effective_mesh_url(), "http://inferadb-engine.inferadb:9191");
711-
}
712604
}

crates/inferadb-control-engine-client/Cargo.toml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)