use crate::{
machines::WFCommand,
workflow::{ActivationListener, WorkflowFetcher},
};
use std::sync::mpsc::{self, Receiver, Sender};
#[derive(Debug)]
pub(crate) struct WorkflowBridge {
incoming_commands: Receiver<Vec<WFCommand>>,
}
impl WorkflowBridge {
pub(crate) fn new() -> (Self, Sender<Vec<WFCommand>>) {
let (tx, rx) = mpsc::channel();
(
Self {
incoming_commands: rx,
},
tx,
)
}
}
impl WorkflowFetcher for WorkflowBridge {
fn fetch_workflow_iteration_output(&mut self) -> Vec<WFCommand> {
let in_cmds = self.incoming_commands.try_recv();
let in_cmds = in_cmds.unwrap_or_else(|_| vec![WFCommand::NoCommandsFromLang]);
debug!(in_cmds = ?in_cmds, "wf bridge iteration fetch");
in_cmds
}
}
impl ActivationListener for WorkflowBridge {}