Skip to content

Commit 556725d

Browse files
feat: manager service (#2793)
## Problem The *supervisor* type lives in the *agama-server* package which depends on the *agama_lib* package. The http events are provided by *agama_lib*, and it needs to know the event type of each service. This makes impossible to emit events from the supervisor service because of cyclic dependencies. ## Solution Extract the *supervisor* to its own package, taking the opportunity for renaming it as *agama-manager*. Note that the supervisor concept is too related to the actors terminology.
2 parents 9643090 + 36ed02e commit 556725d

File tree

26 files changed

+141
-122
lines changed

26 files changed

+141
-122
lines changed

rust/Cargo.lock

Lines changed: 22 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ members = [
55
"agama-l10n",
66
"agama-lib",
77
"agama-locale-data",
8+
"agama-manager",
89
"agama-network",
910
"agama-server",
1011
"agama-utils",

rust/agama-lib/src/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
mod base_http_client;
2222
pub use base_http_client::{BaseHTTPClient, BaseHTTPClientError};
2323

24-
mod event;
24+
pub mod event;
2525
pub use event::{Event, EventPayload};
2626

2727
mod websocket;

rust/agama-lib/src/http/event.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ use agama_l10n as l10n;
3838
use agama_utils::{issue, progress};
3939
use serde::{Deserialize, Serialize};
4040
use std::collections::HashMap;
41+
use tokio::sync::broadcast;
42+
43+
pub type Sender = broadcast::Sender<Event>;
44+
pub type Receiver = broadcast::Receiver<Event>;
4145

4246
/// Agama event.
4347
///

rust/agama-manager/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "agama-manager"
3+
version = "0.1.0"
4+
rust-version.workspace = true
5+
edition.workspace = true
6+
7+
[dependencies]
8+
agama-lib = { path = "../agama-lib" }
9+
agama-utils = { path = "../agama-utils" }
10+
agama-l10n = { path = "../agama-l10n" }
11+
thiserror = "2.0.12"
12+
serde = { version = "1.0.210", features = ["derive"] }
13+
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread", "sync"] }
14+
tokio-stream = "0.1.16"
15+
async-trait = "0.1.83"
16+
serde_json = "1.0.128"
17+
utoipa = { version = "5.2.0", features = ["axum_extras", "uuid"] }
18+
strum = { version = "0.27.2", features = ["derive"] }
19+
tracing = "0.1.40"
20+
zbus = { version = "5", default-features = false, features = ["tokio"] }
21+
merge-struct = "0.1.0"
22+
23+
[dev-dependencies]
24+
tokio-test = "0.4.4"
25+
26+
[lints.rust]
27+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(ci)'] }

rust/agama-server/src/supervisor/listener.rs renamed to rust/agama-manager/src/listener.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
// To contact SUSE LLC about this file by physical or electronic mail, you may
1919
// find current contact information at www.suse.com.
2020

21-
use crate::web::EventsSender;
22-
use agama_lib::http::{Event, EventPayload};
21+
use agama_lib::http;
2322
use std::pin::Pin;
2423
use tokio::sync::mpsc;
2524
use tokio_stream::{wrappers::UnboundedReceiverStream, Stream, StreamExt, StreamMap};
@@ -30,12 +29,12 @@ use tokio_stream::{wrappers::UnboundedReceiverStream, Stream, StreamExt, StreamM
3029
/// `agama_l10n::Event`) and has to be converted to the [Event
3130
/// struct](agama_lib::http::Event).
3231
pub struct EventsListener {
33-
inner: StreamMap<&'static str, Pin<Box<dyn Stream<Item = Event> + Send>>>,
34-
sender: EventsSender,
32+
inner: StreamMap<&'static str, Pin<Box<dyn Stream<Item = http::Event> + Send>>>,
33+
sender: http::event::Sender,
3534
}
3635

3736
impl EventsListener {
38-
pub fn new(sender: EventsSender) -> Self {
37+
pub fn new(sender: http::event::Sender) -> Self {
3938
EventsListener {
4039
inner: StreamMap::new(),
4140
sender,
@@ -47,10 +46,10 @@ impl EventsListener {
4746
name: &'static str,
4847
channel: mpsc::UnboundedReceiver<T>,
4948
) where
50-
EventPayload: From<T>,
49+
http::EventPayload: From<T>,
5150
{
52-
let stream =
53-
UnboundedReceiverStream::new(channel).map(|e| Event::new(EventPayload::from(e)));
51+
let stream = UnboundedReceiverStream::new(channel)
52+
.map(|e| http::Event::new(http::EventPayload::from(e)));
5453
self.inner.insert(name, Box::pin(stream));
5554
}
5655

rust/agama-server/src/supervisor/message.rs renamed to rust/agama-manager/src/message.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
// To contact SUSE LLC about this file by physical or electronic mail, you may
1919
// find current contact information at www.suse.com.
2020

21-
use std::collections::HashMap;
22-
23-
use crate::supervisor::{
21+
use crate::{
2422
l10n, proposal::Proposal, scope::ConfigScope, scope::Scope, service, system_info::SystemInfo,
2523
};
2624
use agama_lib::{install_settings::InstallSettings, issue::Issue};
2725
use agama_utils::{actor::Message, progress::Progress};
2826
use serde::{Deserialize, Serialize};
27+
use std::collections::HashMap;
2928

3029
/// Gets the installation status.
3130
pub struct GetStatus;

rust/agama-server/src/supervisor/proposal.rs renamed to rust/agama-manager/src/proposal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// To contact SUSE LLC about this file by physical or electronic mail, you may
1919
// find current contact information at www.suse.com.
2020

21-
use crate::supervisor::l10n;
21+
use crate::l10n;
2222
use serde::Serialize;
2323

2424
#[derive(Clone, Debug, Serialize)]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// To contact SUSE LLC about this file by physical or electronic mail, you may
1919
// find current contact information at www.suse.com.
2020

21-
use crate::supervisor::l10n;
21+
use crate::l10n;
2222
use serde::{Deserialize, Serialize};
2323

2424
#[derive(

0 commit comments

Comments
 (0)