summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge_api/examples/heartbeat.rs
AgeCommit message (Collapse)Author
2022-06-23Merge remote-tracking branch 'gitlab-marcel/feature/add_tedge_api_only' into ↵Matthias Beyer
feature/add_tedge_api/integrate-api This merge integrates the latest changes from the API into the implementation, into an integration branch. The important change this merges is commit 10ef8e00bd7c78ed709c933edd92a59cc885e341 ("Change TypeUuid implementation to bevy_reflect") which changes a part of the plugin API. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-06-23Change TypeUuid implementation to bevy_reflectMatthias Beyer
This patch replaces the type_uuid crate with the bevy_reflect implementation of the functionality. The rationale for this is, that the implementation of the type_uuid crate does not support generics, but the bevy_reflect implementation does. As we need generic support for type uuids, we change to bevy_reflect here. Suggested-by: Marcel Müller <m.mueller@ifm.com> Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-05-31Merge remote-tracking branch 'gitlab-marcel/feature/add_tedge_api_only' into ↵Matthias Beyer
feature/add_tedge_api/integrate-api-changes This merges the latest changes in the API, which features (mainly) the type-uuid changes from commit 02bfa3768be59b211daddd9b66203b787fd72153 ("Add TypeUUID to Messages"). This merge is done onto the integration branch, so we can adapt to the new API in the next few commits and then merge the integration branch back into the implementation. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
2022-05-31Add TypeUUID to MessagesMarcel Müller
This allows messages to be identified by their UUID. This means that messages are no longer identified by the internal TypeId as provided from rustc but our choosing. This allows for more powerful features along the line, such as external programs being able to specify messages at all. Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-05-31Move Message to message.rsMarcel Müller
Signed-off-by: Marcel Müller <m.mueller@ifm.com>
2022-05-20Merge remote-tracking branch 'gitlab-marcel/feature/add_tedge_api_only' into ↵Matthias Beyer
feature/add_tedge_api/integrate-api This merges the latest changes from the API branch into an integration branch for adapting the the core implementation to the changes. The changes, most notably commit 43ed68145e7044c0d8f170af794d71c2fa93599a ("Replace tokio MPSC with a direct Future") were the MPSC interfaces were removed from the API, will result in quite a few adaptions in the tedge_core crate implementation. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
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-10Merge commit '93460d4' into feature/add_tedge_api/integrate-apiMatthias Beyer
Merge in the changes in the API that allow catchall message handler implementations. Signed-off-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-28Merge commit 'a398c97' into feature/add_tedge_api/integrate-api-changesMatthias Beyer
This merge integrates the latest updates to the tedge_api into the implementation in the feature/add_tedge_api branch, via a integration helper branch. Further commits to this branch will adapt our uses of the API to the new interface so that these changes can then be merged back into feature/add_tedge_api. Signed-off-by: Matthias Beyer <matthias.beyer@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-13Fix: Add PluginDirectory::get_address_for_self() impl in exampleMatthias Beyer
Fixes: d010a66edfb4ba557b22d1259bd08deeebc96923 ("Add PluginDirectory::get_address_for_self()") Signed-off-by: Matthias Beyer <matthias.beyer@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>