Skip to content

Commit ca6f8cf

Browse files
committed
feat: added respond signal
1 parent cf0b020 commit ca6f8cf

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/context/signal.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@ use crate::error::RuntimeError;
33

44
#[derive(Debug)]
55
pub enum Signal {
6+
// Will be signaled if a function has been executed successfully
67
Success(Value),
8+
// Will be signaled if
9+
// - a function recieves wrong parameter
10+
// - a function throws an error
11+
// - taurus itself throwns an error
12+
// - will stop the execution of the flow completly
713
Failure(RuntimeError),
14+
// Will be signaled if the `return` function has been executed
15+
// - will break the current context and return the value to the upper node
816
Return(Value),
17+
// Will be signaled if the `respond` function has been executed
18+
// - will stop the execution of the flow completly
19+
// - will return the value to the adapter
20+
Respond(Value),
21+
// Will be signaled if the `stop` function has been executed
22+
// - will stop the execution of the flow completly
923
Stop
1024
}
1125

@@ -17,6 +31,7 @@ impl PartialEq for Signal {
1731
| (Signal::Failure(_), Signal::Failure(_))
1832
| (Signal::Return(_), Signal::Return(_))
1933
| (Signal::Stop, Signal::Stop)
34+
| (Signal::Respond(_), Signal::Respond(_))
2035
)
2136
}
22-
}
37+
}

src/executor/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl<'a> Executor<'a> {
4747
}
4848
Signal::Failure(error) => return Signal::Failure(error),
4949
Signal::Stop => return Signal::Stop,
50+
Signal::Respond(value) => return Signal::Respond(value)
5051
}
5152
}
5253

@@ -71,6 +72,7 @@ impl<'a> Executor<'a> {
7172
}
7273
Signal::Failure(runtime_error) => return Signal::Failure(runtime_error),
7374
Signal::Return(value) => return Signal::Return(value),
75+
Signal::Respond(value) => return Signal::Respond(value),
7476
Signal::Stop => return Signal::Stop,
7577
}
7678
}

0 commit comments

Comments
 (0)