mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2025-04-21 19:56:25 +02:00
Compare commits
2 Commits
d5fe7cbe5c
...
646aae8ef5
Author | SHA1 | Date | |
---|---|---|---|
646aae8ef5 | |||
95241a6fd0 |
@ -243,12 +243,16 @@ pub fn load(
|
||||
.compat(),
|
||||
);
|
||||
|
||||
let mut actor_map: HashMap<String, _> = config
|
||||
.actor_connections
|
||||
let mut actor_connections_data_vec: Vec<(String, String)> = vec![];
|
||||
for actor_connection in config.actor_connections.clone().into_iter() {
|
||||
actor_connections_data_vec.push((actor_connection.machine, actor_connection.actor));
|
||||
}
|
||||
|
||||
let mut actor_map: HashMap<String, _> = actor_connections_data_vec
|
||||
.iter()
|
||||
.filter_map(|(k, v)| {
|
||||
if let Some(resource) = resources.get_by_id(v) {
|
||||
Some((k.clone(), resource.get_signal()))
|
||||
if let Some(resource) = resources.get_by_id(k) {
|
||||
Some((v.clone(), resource.get_signal()))
|
||||
} else {
|
||||
tracing::error!(actor=%k, machine=%v, "Machine configured for actor not found!");
|
||||
None
|
||||
|
@ -90,11 +90,11 @@ pub struct Config {
|
||||
|
||||
/// Actors to load and their configuration options
|
||||
pub actors: HashMap<String, ModuleConfig>,
|
||||
pub actor_connections: HashMap<String, String>,
|
||||
pub actor_connections: Vec<ActorConnectionConfig>,
|
||||
|
||||
/// Initiators to load and their configuration options
|
||||
pub initiators: HashMap<String, ModuleConfig>,
|
||||
pub init_connections: HashMap<String, String>,
|
||||
pub init_connections: Vec<InitiatorConnectionConfig>,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@ -109,6 +109,24 @@ pub struct ModuleConfig {
|
||||
pub params: HashMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ParamsConfig {
|
||||
pub module: String,
|
||||
pub params: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ActorConnectionConfig {
|
||||
pub machine: String,
|
||||
pub actor: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct InitiatorConnectionConfig {
|
||||
pub machine: String,
|
||||
pub initiator: String,
|
||||
}
|
||||
|
||||
pub(crate) fn deser_option<'de, D, T>(d: D) -> std::result::Result<Option<T>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
@ -124,6 +142,21 @@ impl Default for Config {
|
||||
let mut roles: HashMap<String, Role> = HashMap::new();
|
||||
let mut machines: HashMap<String, MachineDescription> = HashMap::new();
|
||||
|
||||
let mut initiator_123_params: HashMap<String, String> = HashMap::new();
|
||||
initiator_123_params.insert("args".to_string(), "".to_string());
|
||||
initiator_123_params.insert("cmd".to_string(), "echo".to_string());
|
||||
|
||||
let mut actor_connections_vec: Vec<ActorConnectionConfig> = vec![ActorConnectionConfig {
|
||||
machine: "resource_a".to_string(),
|
||||
actor: "actor_123".to_string(),
|
||||
}];
|
||||
|
||||
let mut initiator_connections_vec: Vec<InitiatorConnectionConfig> =
|
||||
vec![InitiatorConnectionConfig {
|
||||
machine: "resource_a".to_string(),
|
||||
initiator: "initiator_123".to_string(),
|
||||
}];
|
||||
|
||||
roles.insert(
|
||||
"admin".to_string(),
|
||||
Role {
|
||||
@ -223,7 +256,7 @@ impl Default for Config {
|
||||
"initiator_123".to_string(),
|
||||
ModuleConfig {
|
||||
module: "Process".to_string(),
|
||||
params: HashMap::new(),
|
||||
params: initiator_123_params,
|
||||
},
|
||||
);
|
||||
|
||||
@ -248,9 +281,9 @@ impl Default for Config {
|
||||
roles,
|
||||
machines,
|
||||
actors,
|
||||
actor_connections: vec!(("actor".to_string(), "actor_123".to_string()), ("machine".to_string(),"resource_a".to_string())).into_iter().collect(),
|
||||
actor_connections: actor_connections_vec,
|
||||
initiators,
|
||||
init_connections: vec!(("initiator".to_string(), "initiator_123".to_string()), ("machine".to_string(),"resource_b".to_string())).into_iter().collect(),
|
||||
}
|
||||
init_connections: initiator_connections_vec,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,12 +103,16 @@ pub fn load(
|
||||
let span = tracing::info_span!("loading initiators");
|
||||
let _guard = span.enter();
|
||||
|
||||
let mut initiator_map: HashMap<String, Resource> = config
|
||||
.init_connections
|
||||
let mut init_connections_data_vec: Vec<(String, String)> = vec![];
|
||||
for init_connection in config.init_connections.clone().into_iter() {
|
||||
init_connections_data_vec.push((init_connection.machine, init_connection.initiator));
|
||||
}
|
||||
|
||||
let mut initiator_map: HashMap<String, Resource> = init_connections_data_vec
|
||||
.iter()
|
||||
.filter_map(|(k, v)| {
|
||||
if let Some(resource) = resources.get_by_id(v) {
|
||||
Some((k.clone(), resource.clone()))
|
||||
if let Some(resource) = resources.get_by_id(k) {
|
||||
Some((v.clone(), resource.clone()))
|
||||
} else {
|
||||
tracing::error!(initiator=%k, machine=%v,
|
||||
"Machine configured for initiator not found!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user