-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose the software service through the HTTP/JSON API (#1069)
Trello: https://trello.com/c/2MjaulMd/3566-3-expose-the-software-api-over-http This PR exposes the public[^1] part of the software API through the HTTP/JSON interface. It includes: * `/software/patterns`: list of patterns, including whether they are selected (and by whom). * `/software/products`: list of products. * `/software/probe`: starts the software probing. * `/software/config`: describing the software configuration. ```json { "patterns": [ "gnome" ], "product": "Tumbleweed" } ``` Additionally, it exposes the following events through the websocket: * `PatternsChanged`, containing the patterns and who selected them ('user' or 'auto'). * `ProductChanged`, with the name of the new product. [^1] The part of the D-Bus API that it is used by the web UI. ## Implementation details In this phase of the development, we are still deciding the best way to implement these HTTP/JSON interfaces. The implementation has two parts: * The [HTTP/JSON interface itself](https://github.com/openSUSE/agama/blob/http-software-srv/rust/agama-server/src/software/web.rs#L104), which is implemented as a [Router](https://docs.rs/axum/latest/axum/struct.Router.html) and a set of small functions (one per each endpoing+verb). * An [events stream](https://github.com/openSUSE/agama/blob/http-software-srv/rust/agama-server/src/software/web.rs#L60) which emits Event values (see [stream](https://tokio.rs/tokio/tutorial/streams) in the Tokio documentation). About the service status, the zbus proxies are cached and can be cloned, so it looks like a good idea to keep our clients as part of the state. ## In the future There are a few improvements we could consider in the future: * Split the events in different types depending on the service (`SoftwareEvent`, `ManagerEvent`), so those services only know about their types. * Consolidate all errors under a common one (e.g., `Error::Software(SoftwareError)`, `Error::Manager(ManagerError)`, etc.) to have a single `IntoResponse` implementation while keeping modules isolation.
- Loading branch information
Showing
14 changed files
with
433 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod web; | ||
pub use web::{software_service, software_stream}; |
Oops, something went wrong.