Skip to content

Commit 4707a2f

Browse files
committed
Refactor AimDB to remove Spawn trait and collect futures in build()
- Updated `WebSocketConnectorImpl` to collect outbound publisher futures instead of spawning them directly. - Refactored `ServerState` to build the WebSocket Axum server future and return it as a `BoxFuture`. - Revised design documentation to reflect the removal of the `Spawn` trait and the new approach for handling futures. - Modified examples to adapt to the new `build()` and `run()` pattern, ensuring proper initialization and concurrent execution of tasks. - Removed unnecessary `Spawn` trait bounds from various components and updated related code generation. - Cleaned up example projects to align with the new architecture, including adjustments to how the Embassy adapter is initialized and how the database runner is executed.
1 parent 75d6cf9 commit 4707a2f

54 files changed

Lines changed: 1276 additions & 1668 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ tracing = { version = "0.1", default-features = false }
7575

7676
# Async utilities
7777
futures = "0.3"
78+
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }
7879

7980
# CLI (for aimdb-cli)
8081
clap = { version = "4.0", features = ["derive"] }

aimdb-codegen/src/rust.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ fn emit_imports(state: &ArchitectureState) -> TokenStream {
557557
use aimdb_core::builder::AimDbBuilder;
558558
use aimdb_core::RecordKey;
559559
use aimdb_data_contracts::{#(#contract_traits),*};
560-
use aimdb_executor::Spawn;
560+
use aimdb_executor::RuntimeAdapter;
561561
use serde::{Deserialize, Serialize};
562562
}
563563
}
@@ -731,7 +731,7 @@ fn emit_configure_schema(state: &ArchitectureState) -> TokenStream {
731731
/// addresses. Producers, consumers, serializers, and deserializers contain
732732
/// business logic and must be provided by application code — they are not
733733
/// generated here.
734-
pub fn configure_schema<R: Spawn + 'static>(builder: &mut AimDbBuilder<R>) {
734+
pub fn configure_schema<R: RuntimeAdapter + 'static>(builder: &mut AimDbBuilder<R>) {
735735
#(#record_blocks)*
736736
}
737737
}
@@ -1250,7 +1250,7 @@ pub fn generate_hub_schema_rs(state: &ArchitectureState) -> String {
12501250
let file_tokens = quote! {
12511251
use aimdb_core::buffer::BufferCfg;
12521252
use aimdb_core::builder::AimDbBuilder;
1253-
use aimdb_executor::Spawn;
1253+
use aimdb_executor::RuntimeAdapter;
12541254
use #common_crate::*;
12551255

12561256
#configure_fn
@@ -1833,8 +1833,8 @@ url = "mqtt://ota/cmd/{variant}"
18331833
"Missing RecordKey import:\n{out}"
18341834
);
18351835
assert!(
1836-
out.contains("use aimdb_executor::Spawn;"),
1837-
"Missing Spawn import:\n{out}"
1836+
out.contains("use aimdb_executor::RuntimeAdapter;"),
1837+
"Missing RuntimeAdapter import:\n{out}"
18381838
);
18391839
assert!(
18401840
out.contains("use serde::{Deserialize, Serialize};"),
@@ -1938,7 +1938,7 @@ url = "mqtt://ota/cmd/{variant}"
19381938
let out = generated();
19391939
assert!(
19401940
out.contains(
1941-
"pub fn configure_schema<R: Spawn + 'static>(builder: &mut AimDbBuilder<R>)"
1941+
"pub fn configure_schema<R: RuntimeAdapter + 'static>(builder: &mut AimDbBuilder<R>)"
19421942
),
19431943
"Missing configure_schema function:\n{out}"
19441944
);

0 commit comments

Comments
 (0)