Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve message handler pluggability #17

Closed
stoyan-zoubev opened this issue Sep 19, 2022 · 0 comments · Fixed by #29
Closed

Improve message handler pluggability #17

stoyan-zoubev opened this issue Sep 19, 2022 · 0 comments · Fixed by #29
Assignees
Labels
task Single unit of work
Milestone

Comments

@stoyan-zoubev
Copy link
Contributor

Currently registries are used to store command and telemetry message handler instances. Message handler implementations are private and register themselves in the respective registries using golang init functions. On the other side, the app launcher uses these registries while starting the azure connector.

In order to allow easy extensions and customization by adding new handler implementations, the current scheme may be modified. A better approach is to:

  • get rid of the internal registries
  • make handler implementations public or add public methods to create new handler instances
  • main method shall instantiate message handlers and pass these instances to the launcher's MainLoop.

Thus, main method has the full control over the message handlers. It can easily add new handlers or remove some of the handlers, e.g. don't use the default passthrough command handler if you do not want all the cloud messages to be forwarded locally.

Additionally the common Azure settings (connection string, sas token validity, idscope, local broker settings, log settings, etc.) should be decoupled from handler-specific settings. So that when doing extensions/customizations, e.g. disabling/replacing passthrough command handler, its settings will not be needed at all. A separate issue will be posted to cover this topic.

@e-grigorov e-grigorov added the task Single unit of work label Sep 19, 2022
@e-grigorov e-grigorov moved this to Todo in Eclipse Kanto Sep 19, 2022
@konstantina-gramatova konstantina-gramatova added this to the M3 milestone Sep 29, 2022
stoyan-zoubev added a commit to SoftwareDefinedVehicle/kanto-azure-connector that referenced this issue Oct 12, 2022
- removed internal registries for telemetry and command handlers
- launcher now expects to get handlers instead of using the internal registries
- handlers.go moved from message/handlers/common to message/handlers, package changed to handlers, common directory deleted
- packages command and telemetry merged into one package passthrough
- message/handlers/command/passthrough_handler_*.go moved as message/handlers/passthrough/command_handler_*.go
- message/handlers/telemetry/passthrough_handler_*.go moved as message/handlers/passthrough/telemetry_handler_*.go
- "passthrough" strings inside the source files removed as it now matches the package name
- removed unused stopRouter method from main.go

Signed-off-by: Stoyan Zoubev <[email protected]>
@stoyan-zoubev stoyan-zoubev moved this from Todo to In Progress in Eclipse Kanto Oct 12, 2022
@stoyan-zoubev stoyan-zoubev moved this from In Progress to Ready for Review in Eclipse Kanto Oct 12, 2022
@e-grigorov e-grigorov linked a pull request Oct 13, 2022 that will close this issue
@e-grigorov e-grigorov moved this from Ready for Review to In Review in Eclipse Kanto Oct 13, 2022
e-grigorov pushed a commit that referenced this issue Oct 13, 2022
[#17] Improve message handler pluggability

- removed internal registries for telemetry and command handlers
- launcher now expects to get handlers instead of using the internal registries
- handlers.go moved from message/handlers/common to message/handlers, package changed to handlers, common directory deleted
- packages command and telemetry merged into one package passthrough
- message/handlers/command/passthrough_handler_*.go moved as message/handlers/passthrough/command_handler_*.go
- message/handlers/telemetry/passthrough_handler_*.go moved as message/handlers/passthrough/telemetry_handler_*.go
- "passthrough" strings inside the source files removed as it now matches the package name
- removed unused stopRouter method from main.go

Signed-off-by: Stoyan Zoubev <[email protected]>
Repository owner moved this from In Review to Done in Eclipse Kanto Oct 13, 2022
stoyan-zoubev added a commit to SoftwareDefinedVehicle/kanto-azure-connector that referenced this issue Oct 13, 2022
- Separate interfaces for c2d and d2c messages - CommandHandler and TelemetryHandler
- Removed AzureSettings parameter from handler Init method, static parameters should be passed to handler constructors.
- MessageHandler.Init method receives cloud connection info only (this is data that may not be known at the time of handler creation) - Device ID, Hostname, etc.
- Simplified test methods

Signed-off-by: Stoyan Zoubev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Single unit of work
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants