Merged
Conversation
- Introduced `TokioAdapter` for async task spawning and execution. - Implemented time-related capabilities including timestamps and sleep. - Updated feature flags in `Cargo.toml` for tracing and optional dependencies.
4 tasks
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements runtime adapter integration for AimDB, establishing the foundation for async task execution across different runtime environments (Tokio and Embassy). The implementation includes core traits for runtime and time operations, along with concrete adapters for both std and no_std environments.
Key changes:
- Core runtime and time traits defining the adapter interface
- Tokio adapter for std environments with full async runtime support
- Embassy adapter for embedded/no_std environments with Embassy executor integration
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| aimdb-core/src/lib.rs | Exports new runtime and time traits |
| aimdb-core/src/runtime.rs | Defines core RuntimeAdapter and DelayCapableAdapter traits |
| aimdb-core/src/time.rs | Implements TimestampProvider and SleepCapable traits with utilities |
| aimdb-core/Cargo.toml | Adds tokio dev dependency for async testing |
| aimdb-tokio-adapter/src/lib.rs | Updates module structure and documentation for runtime integration |
| aimdb-tokio-adapter/src/runtime.rs | Implements TokioAdapter with RuntimeAdapter and DelayCapableAdapter |
| aimdb-tokio-adapter/src/time.rs | Provides Tokio-specific time implementations |
| aimdb-tokio-adapter/Cargo.toml | Adds tracing and futures dependencies |
| aimdb-embassy-adapter/src/lib.rs | Exports new runtime and time modules |
| aimdb-embassy-adapter/src/runtime.rs | Implements EmbassyAdapter for embedded environments |
| aimdb-embassy-adapter/src/time.rs | Provides Embassy-specific time implementations |
| aimdb-embassy-adapter/Cargo.toml | Adds tracing and testing dependencies |
…me service spawning capabilities
…ate service macro for automatic context injection
…eplacing 'embedded' with 'no_std minimal' and adjusting feature validation tests for clarity.
…arify no_std requirements for aimdb-core and aimdb-embassy-adapter
… and error handling, including new executor traits and improved feature definitions.
…handling, updating AimDbService implementation for better integration with Tokio and Embassy runtimes.
…s, updating service spawning methods and error handling for improved runtime integration.
…dating dependencies and error handling for better compatibility with async tasks.
…n, and error methods
…proved organization and clarity
…methods for improved time handling
…mproved time handling
…log and time accessors for improved code clarity and efficiency
…er API and improved service spawning
Enhance core library structure and exports Introduce metrics tracking for producer-consumer patterns Implement producer-consumer pattern with self-registering records Add tracked async function wrapper for automatic call tracking Develop type-safe record storage using TypeId
… improve builder API
…s for version, edition, and license
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Remove global static adapter initialization and related methods for cleaner API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8.
Changelog: Runtime Adapter Integration
Overview
This PR implements comprehensive runtime adapter integration for AimDB, enabling seamless async operations across both standard (Tokio) and embedded (Embassy) runtimes. This addresses issue #8 and establishes the foundation for AimDB's cross-platform async capabilities.
🎯 Major Features
1. Unified Runtime Abstraction Layer
aimdb-executorcrate with runtime-agnostic traits:RuntimeAdapter- Core runtime identificationSpawn- Dynamic task spawning capabilitiesTimeOps- Unified time operations (now, duration, sleep)Logger- Runtime-appropriate loggingRuntime- Composite trait combining all capabilitiesstd,tokio-runtime, andembassy-runtime2. Tokio Runtime Integration (
aimdb-tokio-adapter)stdruntime support with Tokio executortokio::spawntokio::timetracingcrateTokioDatabasewith unified builder APIexamples/tokio-runtime-demo3. Embassy Runtime Integration (
aimdb-embassy-adapter)no_stdembedded runtime support#[embassy_executor::task])embassy_timedefmtEmbassyDatabasewith spawner-aware builderexamples/embassy-runtime-demo(STM32H563ZI target)4. Enhanced Core Database (
aimdb-core)RuntimeContextfor unified runtime accessTypeIdfor type safetytracked_fnmacroDatabase<A>over any runtime adapter5. Shared Examples Infrastructure
aimdb-examples-sharedcrate with reusable service implementationsdata_processor_service- Demonstrates async data processingmonitoring_service- Shows metrics collectionRuntimeContext🔧 Technical Improvements
Error Handling
DbErrorwith runtime-specific variantsExecutorErrorfor runtime operation failuresTime Operations
millis,secs,micros)TimeSourcetrait with instant comparisonsLogging
Loggertraittracingfor std environmentsdefmtfor embedded targetsBuild System
examplestarget for building all examplesallcommand includes examples📦 New Crates & Modules
New Crates
aimdb-executor- Runtime trait definitionsaimdb-tokio-adapter- Tokio runtime implementationaimdb-embassy-adapter- Embassy runtime implementation (refactored)aimdb-examples-shared- Shared service codeNew Modules in
aimdb-coreruntime.rs- Runtime context and base traitsemitter.rs- Cross-record communicationmetrics.rs- Performance trackingproducer_consumer.rs- Producer-consumer patterntracked_fn.rs- Async function trackingtyped_record.rs- Type-safe record storage🧪 Examples & Demos
Producer-Consumer Demo (
examples/producer-consumer-demo)tracked_fnTokio Runtime Demo (
examples/tokio-runtime-demo)RuntimeContextEmbassy Runtime Demo (
examples/embassy-runtime-demo)