name: add-extension
description: Add a new extension of tedge-mapper or tedge-agent as an actor.
Add Extension
Steps
- Create extension actor crate
crates/extensions/<name>/withsrc/lib.rs,src/actor.rs,src/builder.rs,src/messages.rs - Generate
Cargo.tomlwith workspace conventions:[package] name = "<name>" version.workspace = true edition.workspace = true license.workspace = true [lints] workspace = true [dependencies] tedge_actors = { workspace = true } # add other workspace deps as needed - Define message types in
messages.rs(implementMessage: Debug + Send + Sync + 'static) - Define actor in
actor.rs:- Struct with a message box field (e.g.,
ServerMessageBox<Request, Response>orSimpleMessageBox<Input, Output>) - Implement
Actortrait:fn name(&self) -> &str,async fn run(self) -> Result<(), RuntimeError>
- Struct with a message box field (e.g.,
- Define builder in
builder.rs:- Implement
Builder<T>,RuntimeRequestSink - Implement
MessageSink<M>andMessageSource<M, Config>for wiring - Use
SimpleMessageBoxBuilder(event-driven) orServerMessageBoxBuilder(request-response)
- Implement
- Add crate to workspace
Cargo.toml— extensions use glob (crates/extensions/*) so no manual addition needed - Register with the agent in
crates/core/tedge_agent/src/agent.rs: - Verify: Run
just checkandjust test
Reference Files
Read these for patterns:
crates/extensions/tedge_timer_ext/— server-based actor withServerMessageBox, builder, and testscrates/extensions/tedge_signal_ext/src/lib.rs— minimal actor usingSimpleMessageBoxcrates/core/tedge_mapper/src/lib.rs— mapper registration andlookup_component()