summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge_api/examples/heartbeat.rs
AgeCommit message (Collapse)Author
2022-05-20Replace tokio MPSC with a direct FutureMarcel Müller
MPSC are a heavy form of indirection that is potentially not needed. This patch removes them and instead opts to use a Fn Generator of futures that correspond to the model of communication One Question -> One Reponse. Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com> Reviewed-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-05-05Add AnyMessage & AnyMessagesMarcel Müller
This patch adds the ability to send any kind of messages to plugins that declare handling `AnyMessage` + `AnyMessages`. It does it with these changes: - Remove the `Message::Reply` associated type - This allows `Message` to be used as a trait object - Add the `MessageType` which allows to identify messages - This permits `AnyMessage` to be received by plugins Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-04-27Rename send to send_and_waitMarcel Müller
Make it clear that sending messages can potentially block indefinitely if the target plugin does not handle them. Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-04-13Replace PluginError with miette::ErrorMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-04-13Adapt names with documentation to be more fittingMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-04-13Remove spanned wrapper for toml config in pluginsMarcel Müller
While having spanning information is very important for good error messages, the current system is not very well suited for it anyway. This patch removes the spanned wrapper to simplify current implementations, with an outlook to a better replacement. Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-04-11Add PluginDeclaration traitMarcel Müller
This trait simplifies a lot of the message calls in the PluginBuilder. Advantages: You only declare a list of handled messages _once_. This is necessary since Rust does not allow 'queries' for types (aka "give me a tuple of supported types" does not exist), and so the necessary crutch is to declare them manually. Disadvantages: You cannot pick at Runtime anymore what messages you decide to support. This is considered to be a very niche use-case and might actually be an anti-pattern. Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-22Re-export CancellationTokenMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-22Rename: tedge_comms -> plugin_dirMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com> Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-22Add dedicated error type for PluginDirectory interfaceMatthias Beyer
This patch adds a dedicated error type for the PluginDirectory trait interface. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com> Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-21Add cancellation tokenMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-21Rename handler creation to reflect the operationMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-21Separate Message/ReceiverBundleMarcel Müller
Previously they were mixed up, having them separate makes it clear that the bundle made by the `make_receiver_bundle` macro are only meant to be used for _receiving_ plugins. Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-21Add reply functionality to messagesMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-21Add documentation to exampleMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-21Add documentationMarcel Müller
2022-03-21Add typed Address structMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-21Add typed plugins and their untyped wrappersMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-15Rename Comms to CoreCommunicationMarcel Müller
This makes the name clearer and shows that one speaks to the Core that orchestrates the rest. Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-03-15Adapt example to new interfaceMatthias Beyer
`Message::new()` was made private, so we must use `Comms::new_message()` now. This change was missing in the commit that changed that interface. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com> Fixes: ca5672eebbbdf61ee1994dd0ea13346d117cb755 ("Add Comms::new_message()") Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Add Comms::new_message()Matthias Beyer
This patch adds the Comms::new_message() function, which can be used to construct a new message with the origin automatically set correctly. When the Comms object is passed to a plugin, the plugin can use this function to automatically create a message that contains the right origin. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Merge PluginMessage and CoreMessage to MessageMarcel Müller
Having only a single message type makes the implementation easier and allows for a leaner core. This in turn allows for easier abstractions on the plugin side, as only a single type of messages exists. Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Rename PluginBuilder::name to kind_nameMarcel Müller
This makes it clearer on what name refers to here. As both in the config and in the plugin builder you'd have a 'name' property. Renaming this to 'kind name' makes it clear which part it refers to. Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Make PluginBuilder methods asyncMarcel Müller
Allowing them to be async means that they can do slightly more complicated methods of checking configuration and instantiating plugins. (Like IO to check for file existence, etc..) Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Unify errors into PluginErrorMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Make the plugin instantiation failableMatthias Beyer
This patch makes the PluginBuilder::instantiate() function failable. A plugin may fail during its instantiation (simple things like out of disk, permission errors, but also more sophisticated things like business-case errors). Thus, the instantiation should be failable, to allow proper reporting on the thin-edge side of things as well as graceful shutdown if needed. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com> Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Make PluginBuilder::verify_configuration() receive a &PluginConfigurationMatthias Beyer
The verification the `PluginBuilder` does not need to get the object, it is totally sufficient for the verification if it gets only a reference to it. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com> Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-03-04Add example service to tedge_apiMarcel Müller
A very simple service that is meant to showcase how plugins can be built and their lifecycles. Signed-off-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>