-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the NetworkSystem API (#1147)
## The problem While working in introducing an API to get the runtime configuration of the network, we decided that we were not happy with the current `NetworkSystem` API. There was quite some manual to do when using the API, like dealing with channels and having to explictly move the server to a separate Tokio task. ## The solution This change splits the API into smaller pieces: * `NetworkSystem` is still the main entry point. * `NetworkSystemClient` wraps the `actions` channel and offers a higher-level API by hiding the message passing handling. * `NetworkSystemServer` keeps the network state and dispatches the actions. Beware that this struct is private and the `NetworkSystemClient` should be the only way to communicate with it. * You can get a better idea of how it looks like through the following example (included in the documentation): ```rust let adapter = NetworkManagerAdapter::from_system() .await .expect("Could not connect to NetworkManager."); let dbus = connection() .await .expect("Could not connect to Agama's D-Bus server."); let network = NetworkSystem::new(dbus, adapter); // Start the networking service and get the client for communication. let actions = network.start() .await .expect("Could not start the networking configuration system."); // Perform some action, like getting the list of devices. let devices = client.get_devices().await.unwrap(); ``` ## To do * [ ] Get rid of `NetworkService` as it is not needed anymore. Should we rename `NetworkSystem*`?. * [x] Adapt the HTTP/JSON interface to the new API (partially done).
- Loading branch information
Showing
3 changed files
with
285 additions
and
185 deletions.
There are no files selected for viewing
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
Oops, something went wrong.