Browse Source

Rename config fields to 'definition'

tags/v0.0.0-test.4
Philipp Oppermann 3 years ago
parent
commit
2750ea59b1
2 changed files with 13 additions and 10 deletions
  1. +1
    -1
      binaries/runtime/src/main.rs
  2. +12
    -9
      binaries/runtime/src/operator/mod.rs

+ 1
- 1
binaries/runtime/src/main.rs View File

@@ -107,7 +107,7 @@ async fn main() -> eyre::Result<()> {
.ok_or_else(|| eyre!("received event from unknown operator {id}"))?;
match event {
OperatorEvent::Output { id: data_id, value } => {
if !operator.config().config.outputs.contains(&data_id) {
if !operator.definition().config.outputs.contains(&data_id) {
eyre::bail!("unknown output {data_id} for operator {id}");
}
publish(&node_id, id, data_id, &value, communication.as_ref())


+ 12
- 9
binaries/runtime/src/operator/mod.rs View File

@@ -9,28 +9,31 @@ mod shared_lib;

pub struct Operator {
operator_task: Sender<OperatorInput>,
config: OperatorDefinition,
definition: OperatorDefinition,
}

impl Operator {
pub async fn init(
operator_config: OperatorDefinition,
operator_definition: OperatorDefinition,
events_tx: Sender<OperatorEvent>,
) -> eyre::Result<Self> {
let (operator_task, operator_rx) = mpsc::channel(10);

match &operator_config.config.source {
match &operator_definition.config.source {
OperatorSource::SharedLibrary(path) => {
shared_lib::spawn(path, events_tx, operator_rx).wrap_err_with(|| {
format!(
"failed ot spawn shared library operator for {}",
operator_config.id
operator_definition.id
)
})?;
}
OperatorSource::Python(path) => {
python::spawn(path, events_tx, operator_rx).wrap_err_with(|| {
format!("failed ot spawn Python operator for {}", operator_config.id)
format!(
"failed ot spawn Python operator for {}",
operator_definition.id
)
})?;
}
OperatorSource::Wasm(path) => {
@@ -39,7 +42,7 @@ impl Operator {
}
Ok(Self {
operator_task,
config: operator_config,
definition: operator_definition,
})
}

@@ -52,10 +55,10 @@ impl Operator {
})
}

/// Get a reference to the operator's config.
/// Get a reference to the operator's definition.
#[must_use]
pub fn config(&self) -> &OperatorDefinition {
&self.config
pub fn definition(&self) -> &OperatorDefinition {
&self.definition
}
}



Loading…
Cancel
Save