Skip to content

Conversation

@jarhodes314
Copy link
Contributor

Proposed changes

Enable the built-in bridge to be configured with custom rules, ultimately to help enable a generic mapper.

At the time of creating the PR, I have implemented some parsing logic for a bridge toml template, and for testing purposes, created a main.rs in the tedge_mqtt_bridge crate which reads a given config file and debug-prints the expansion of that template. I believe it supports what we need in order to define the existing bridge rules.

For testing it out, save the following template to a file and run cargo run -p tedge_mqtt_bridge <filename>. You can play around with setting c8y.smartrest.templates and seeing the generated output change as a result. I've experimented with using serde_spanned and ariadne for contextual error reporting with invalid templates.

local_prefix = "${.c8y.bridge.topic_prefix}/"
remote_prefix = ""

[[rule]]
topic = "s/ds"
direction = "inbound"

[[rule]]
local_prefix = "c8y/" # you can override the variables within rules
remote_prefix = ""
topic = "s/us"
direction = "outbound"

[[template_rule]]
for = "${.c8y.smartrest.templates}"
topic = "s/uc/${@for}"
direction = "outbound"

[[template_rule]]
for = "${.c8y.smartrest.templates}"
topic = "s/dc/${@for}"
direction = "inbound"

TODO:

  • Parse a configuration file of bridge rules
  • Make the configuration variable expansion profile-aware
  • Configure the bridge with said rules
  • Integrate this into a mapper so it can run custom rules
  • Persist the default rules from each cloud mapper like we do for flows in feat: az mapper defined using regular flows #3892
  • Document the configuration format

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 76.27119% with 126 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/extensions/tedge_mqtt_bridge/src/config.rs 84.02% 55 Missing and 22 partials ⚠️
crates/extensions/tedge_mqtt_bridge/src/main.rs 0.00% 49 Missing ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: James Rhodes <[email protected]>
@jarhodes314 jarhodes314 force-pushed the poc/configurable-bridge-rules branch from 48fda8b to d10347b Compare January 12, 2026 11:11
Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Aligned with the expectation and working as described.

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