Rust SDK template: trait API, OLink/MQTT/NATS IPC, test-apis#9
Merged
Conversation
test-apis provides the shared input API modules; objectlink-core-rs is the OLink runtime dependency.
5c93395 to
0a22cd6
Compare
Move ApiError/ApiFuture into each module's api crate (api_common) so api and core no longer depend on the apigear support crate. In this template apigear held only those two types, so it is removed along with every `requires apigear`. Restore an ergonomic async operation wrapper: alongside `fn op() -> ApiFuture<Result<T, ApiError>>`, the api exposes `async fn op_async() -> Result<T, ApiError>` via an object-safe extension trait (blanket impl, still works with Arc<dyn Trait>). Adds thiserror to the api crate.
Per-interface integration tests that wire a generated client to a generated service over a real broker/server and assert a round-trip (NATS request/reply + client->service property propagation; MQTT publish + property propagation). Marked #[ignore] so the default cargo test stays broker-free.
New workflow starts Mosquitto and nats-server, then runs the #[ignore]d integration tests with --ignored. Mirrors the python/qtcpp (mosquitto) and cpp17 (nats) templates.
CI revealed the 2s property-propagation timeout was occasionally too tight under load (tb_names MQTT). Widen the poll window to ~6s and the connect/settle delay; the happy path still breaks early, so normal runs stay fast.
namoshek mosquitto 2.0 defaults allow_anonymous=false, so the broker silently rejected connections and property-propagation tests timed out (op-only tests falsely passed). Use the localhost anonymous broker from apt + systemctl, as the cpp17 template does.
Replace the instantiate-only example with runnable demos matching the other templates: a local example exercising every interface (operations, properties, signals) in-process, plus server+client binaries for each IPC (OLink over TCP, MQTT and NATS over a broker/server). Showcase the first interface; default to localhost (override via MQTT_PORT/NATS_URL/OLINK_ADDR). Anchor the .gitignore bin rule to /bin/ so example bin/ dirs are tracked.
CodeQL (actions/missing-workflow-permissions) flagged the workflows for not restricting the default GITHUB_TOKEN. Add an explicit top-level 'permissions: contents: read' to every workflow (they only need read access for checkout).
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.
Summary
Modernized ApiGear Rust SDK template: trait-based API definitions, default
implementations, IPC adapters, a tracing monitor decorator, and integration
tests — generated deterministically and verified end-to-end.
What's in it
asyncviaApiFuture),Publisherwithwatch/broadcastsignal & property channels, serde data structs/enums.tracingdecorator wrapping any implementation.Generation & formatting
cargo fmt-clean output directly — no post-format step.Achieved by disabling rustfmt width reflow (
use_small_heuristics = "Max"),so
go run main.go diffmatches a goldenmaster that also passescargo fmt --check, for any input module.Test inputs
test-apissubmodule (like thepython/cpp/qt/unreal templates) instead of repo-local copies — covering
StructArray2Interface,funcEnum,EmptyInterface, and naming edge cases.Dependencies
objectlink-core-rssubmodule pinned to its published release(
github.com/apigear-io/objectlink-core-rs, includes theError=90wire-protocol fix).Verification
cargo fmt --check,cargo clippy,cargo doc -D warnings: clean.cargo test: 524 passing (incl. OLink loopback round-trips).go run main.go diff: goldenmaster matches fresh generation.CI
ci_generate: regenerates fromtest-apisand diffs against the goldenmaster.ci_build_test: clippy/fmt/test/doc on the goldenmaster (now also triggered bydeps/**submodule bumps).