mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2025-04-18 18:26:26 +02:00
Move to custom structure for actor_connection mapping - test
This commit is contained in:
parent
d5fe7cbe5c
commit
95241a6fd0
@ -243,8 +243,13 @@ 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) {
|
||||
|
@ -90,11 +90,12 @@ 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<(String, String)>,
|
||||
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@ -109,6 +110,18 @@ 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,
|
||||
}
|
||||
|
||||
pub(crate) fn deser_option<'de, D, T>(d: D) -> std::result::Result<Option<T>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
@ -124,6 +137,16 @@ 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()},
|
||||
ActorConnectionConfig {machine: "resource_b".to_string(), actor: "actor_123".to_string()}
|
||||
];
|
||||
|
||||
|
||||
roles.insert(
|
||||
"admin".to_string(),
|
||||
Role {
|
||||
@ -223,7 +246,7 @@ impl Default for Config {
|
||||
"initiator_123".to_string(),
|
||||
ModuleConfig {
|
||||
module: "Process".to_string(),
|
||||
params: HashMap::new(),
|
||||
params: initiator_123_params,
|
||||
},
|
||||
);
|
||||
|
||||
@ -248,9 +271,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: vec![("initiator_123".to_string(), "resource_b".to_string())],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user