Skip to content

Rust SDK template: trait API, OLink/MQTT/NATS IPC, test-apis#9

Merged
w4bremer merged 22 commits into
mainfrom
feat/rust-sdk-ipc-test-apis
Jun 1, 2026
Merged

Rust SDK template: trait API, OLink/MQTT/NATS IPC, test-apis#9
w4bremer merged 22 commits into
mainfrom
feat/rust-sdk-ipc-test-apis

Conversation

@w4bremer
Copy link
Copy Markdown
Contributor

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

  • API: per-interface traits (async via ApiFuture), Publisher with
    watch/broadcast signal & property channels, serde data structs/enums.
  • IPC adapters per interface:
    • OLink (objectlink-core-rs) — client/service + in-process loopback tests.
    • MQTT (rumqttc) — client/service.
    • NATS (async-nats) — client/service.
  • Monitor: tracing decorator wrapping any implementation.
  • Stubs: default trait implementations + per-interface tests.

Generation & formatting

  • Templates emit cargo fmt-clean output directly — no post-format step.
    Achieved by disabling rustfmt width reflow (use_small_heuristics = "Max"),
    so go run main.go diff matches a goldenmaster that also passes
    cargo fmt --check, for any input module.

Test inputs

  • Sources API modules from the shared test-apis submodule (like the
    python/cpp/qt/unreal templates) instead of repo-local copies — covering
    StructArray2Interface, funcEnum, EmptyInterface, and naming edge cases.

Dependencies

  • objectlink-core-rs submodule pinned to its published release
    (github.com/apigear-io/objectlink-core-rs, includes the Error=90 wire-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.
  • Cross-technology interop verified out-of-tree (OLink↔Python, MQTT↔paho, NATS↔nats-py).

CI

  • ci_generate: regenerates from test-apis and diffs against the goldenmaster.
  • ci_build_test: clippy/fmt/test/doc on the goldenmaster (now also triggered by deps/** submodule bumps).
  • Both check out submodules recursively (test-apis + objectlink-core-rs, public).

@w4bremer w4bremer force-pushed the feat/rust-sdk-ipc-test-apis branch from 5c93395 to 0a22cd6 Compare May 30, 2026 00:54
w4bremer added 7 commits June 1, 2026 17:28
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.
Comment thread .github/workflows/ci_ipc_integration.yml Fixed
w4bremer added 4 commits June 1, 2026 18:25
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).
@w4bremer w4bremer merged commit f9db66b into main Jun 1, 2026
6 checks passed
@w4bremer w4bremer deleted the feat/rust-sdk-ipc-test-apis branch June 1, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants