52 bi directional connector trait#53
Merged
Merged
Conversation
- Added `produce_any` method to `ProducerTrait` for type-erased value production. - Updated `RecordRegistrar` to use connector builders instead of direct connectors. - Enhanced error handling for missing connectors and serializers. - Refactored inbound connector task spawning to utilize new routing logic. refactor: Update TypedRecord to support outbound consumer spawning - Introduced `spawn_outbound_consumers` method for managing outbound connector tasks. - Removed redundant inbound connector count and task spawning methods. - Added `create_producer_trait` method for creating type-erased producers. fix: Adjust MQTT connector to use router-based dispatch - Refactored `MqttConnector` to utilize a router for message dispatching. - Updated event loop to route incoming messages to appropriate producers. - Removed deprecated subscribe method in favor of router-based handling. test: Enhance tests for connector spawning and routing - Updated tests to reflect changes in connector registration and routing. - Added mock connector for testing purposes. - Verified correct behavior with no connectors and with registered links. chore: Update dependencies and clean up unused code - Added `async-trait` dependency for async trait support. - Cleaned up unused imports and code comments across various files.
… update type aliases, and adjust resource ID handling for proper memory management in both `std` and `no_std` environments.
- Added support for `embassy-net` in the `Cargo.toml` and `Cargo.lock` files. - Introduced `embassy-net-support` feature in `aimdb-embassy-adapter` for network stack integration. - Updated `MqttConnector` to support bidirectional communication, allowing both publishing and subscribing to MQTT topics. - Implemented `EmbassyNetwork` trait for accessing the network stack within the `EmbassyAdapter`. - Refactored the MQTT connector builder to facilitate the creation of connectors with network capabilities. - Enhanced the example application to demonstrate bidirectional MQTT integration, including command processing from MQTT messages. - Updated documentation and comments for clarity on new features and usage patterns.
…, lifecycle, and implementation details
22 tasks
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces bidirectional connector support for AimDB, enabling simultaneous publishing and subscribing between AimDB and external systems (MQTT, Kafka, etc.). The architecture uses a type-erased router system for automatic message dispatch and implements the ConnectorBuilder pattern for simplified connector registration, with full support for both Tokio (std) and Embassy (no_std) runtimes.
Key Changes:
- New
.link_to()and.link_from()APIs replace generic.link()method for explicit data flow direction - Type-erased Router system automatically routes incoming messages to correct typed producers
- ConnectorBuilder pattern with async initialization during database build phase
- Complete MQTT connector rewrite supporting simultaneous pub/sub with automatic reconnection
- Embassy runtime enhanced with network stack access for connector TCP/UDP operations
Reviewed Changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| aimdb-core/src/builder.rs | Async build() method, connector builder integration, route collection |
| aimdb-core/src/connector.rs | ConnectorBuilder trait, ProducerTrait, InboundConnectorLink |
| aimdb-core/src/router.rs | New router system for type-erased message dispatch |
| aimdb-core/src/typed_api.rs | Bidirectional link APIs (link_to/link_from), builder implementations |
| aimdb-core/src/typed_record.rs | Outbound consumer spawning, inbound connector storage |
| aimdb-mqtt-connector/src/tokio_client.rs | Router-based bidirectional MQTT with automatic subscriptions |
| aimdb-mqtt-connector/src/embassy_client.rs | Embassy MQTT with network stack access, automatic task spawning |
| aimdb-embassy-adapter/src/runtime.rs | EmbassyNetwork trait for connector network access |
| examples/tokio-mqtt-connector-demo/src/main.rs | Bidirectional MQTT demo with command processing |
| examples/embassy-mqtt-connector-demo/src/main.rs | Embedded bidirectional MQTT with network stack integration |
| docs/design/012-M5-connector-development-guide.md | Comprehensive 1000+ line connector development guide |
…mDB → External) from inbound (External → AimDB) flows
- Introduced `spawn_outbound_publishers()` method for both Tokio and Embassy implementations to handle AimDB → MQTT publishing. - Updated `MqttConnectorBuilder` to require outbound publisher spawning during `build()`. - Refactored outbound architecture to utilize `ConsumerTrait` for type-safe message dispatch. - Enhanced documentation to clarify the importance of spawning outbound publishers. - Updated changelog to reflect breaking changes and new features.
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.
Closed #52.
This PR introduces bidirectional connector support, enabling true two-way data synchronization between AimDB and external systems. The new architecture supports simultaneous publishing and subscribing with automatic message routing, working seamlessly across both Tokio (std) and Embassy (no_std) runtimes.
Highlights
.link_to()and.link_from()APIs for clear directional data flowsBreaking Changes
.build()is now async; connector registration changed from.with_connector(scheme, instance)to.with_connector(builder).link()deprecated in favor of.link_to()(outbound) and.link_from()(inbound)MqttConnector::new()toMqttConnectorBuilder::new(); automatic task spawning removes need for manual background task managementModified Crates
See individual changelogs for detailed changes: