Skip to content

Commit 7a74c32

Browse files
Merge pull request #190 from code0-tech/#186-new-module-structure
new module structure
2 parents f1bc017 + c7bb276 commit 7a74c32

39 files changed

Lines changed: 1576 additions & 418 deletions

.github/workflows/build-and-test.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
jobs:
77
taurus:
88
runs-on: ubuntu-latest
9+
services:
10+
nats:
11+
image: nats:2
12+
ports:
13+
- 4222:4222
914

1015
steps:
1116
- uses: actions/checkout@v6
@@ -15,8 +20,11 @@ jobs:
1520
run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo build
1621
env:
1722
RUST_BACKTRACE: 'full'
18-
- name: Run Tests
19-
run: cargo test
20-
- name: Run Test Suite
23+
- name: Run workspace tests
24+
run: cargo test --workspace --all-targets
25+
- name: Run NATS test execution request tests
26+
run: cargo test -p taurus test_execution_request -- --ignored --nocapture
27+
env:
28+
NATS_URL: nats://127.0.0.1:4222
29+
- name: Run tests package flow suite
2130
run: cargo run --package tests
22-

Cargo.lock

Lines changed: 8 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2024"
99
[workspace.dependencies]
1010
async-trait = "0.1.89"
1111
code0-flow = { version = "0.0.33" }
12-
tucana = { version = "0.0.68" }
12+
tucana = { version = "0.0.70" }
1313
tokio = { version = "1.44.1", features = ["rt-multi-thread", "signal"] }
1414
log = "0.4.27"
1515
futures-lite = "2.6.0"

crates/taurus-core/src/handler/argument.rs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,56 @@ use tucana::shared::value::Kind;
77
use tucana::shared::{ListValue, NumberValue, Struct, Value};
88

99
use crate::value::{number_to_f64, number_to_i64_lossy};
10+
use std::fmt;
11+
use tucana::shared::SubFlowSetting;
12+
13+
#[derive(Clone)]
14+
pub struct FunctionThunk {
15+
pub identifier: String,
16+
pub parameter_index: i64,
17+
pub settings: Vec<SubFlowSetting>,
18+
}
19+
20+
impl fmt::Debug for FunctionThunk {
21+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22+
f.debug_struct("FunctionThunk")
23+
.field("identifier", &self.identifier)
24+
.field("parameter_index", &self.parameter_index)
25+
.field("settings_len", &self.settings.len())
26+
.finish()
27+
}
28+
}
29+
30+
#[derive(Clone)]
31+
pub enum Thunk {
32+
Node(i64),
33+
Function(FunctionThunk),
34+
}
35+
36+
impl fmt::Debug for Thunk {
37+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38+
match self {
39+
Thunk::Node(node_id) => write!(f, "{}", node_id),
40+
Thunk::Function(function) => function.fmt(f),
41+
}
42+
}
43+
}
44+
45+
impl Thunk {
46+
pub fn trace_target(&self) -> String {
47+
match self {
48+
Thunk::Node(node_id) => format!("node={}", node_id),
49+
Thunk::Function(function) => format!("function={}", function.identifier),
50+
}
51+
}
52+
}
53+
1054
#[derive(Clone, Debug)]
1155
pub enum Argument {
1256
/// Eager value that can be consumed immediately by a handler.
1357
Eval(Value),
14-
/// Deferred node execution handle, evaluated by calling `run(node_id)`.
15-
Thunk(i64),
58+
/// Deferred execution handle, evaluated by calling `run(thunk)`.
59+
Thunk(Thunk),
1660
}
1761

1862
#[derive(Clone, Copy, Debug)]

crates/taurus-core/src/handler/registry.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
//! Runtime handler registry and callable function signatures.
22
3-
use crate::handler::argument::{Argument, ParameterNode};
3+
use crate::handler::argument::{Argument, ParameterNode, Thunk};
44
use crate::runtime::execution::value_store::ValueStore;
55
use crate::runtime::functions::ALL_FUNCTION_SETS;
66
use crate::types::signal::Signal;
77
use std::collections::HashMap;
88

99
/// Handler function type.
1010
/// - For eager params, the executor will already convert them to Argument::Eval(Value).
11-
/// - For lazy params, the executor will pass Argument::Thunk(node_id).
12-
/// - If a handler wants to execute a lazy arg, it calls run(node_id).
13-
pub type HandlerFn = fn(
11+
/// - For lazy params, the executor will pass Argument::Thunk(thunk).
12+
/// - If a handler wants to execute a lazy arg, it calls run(thunk).
13+
pub type ThunkRunner<'runner> = dyn FnMut(&Thunk, &mut ValueStore) -> Signal + 'runner;
14+
15+
pub type HandlerFn = for<'runner> fn(
1416
args: &[Argument],
1517
ctx: &mut ValueStore,
16-
run: &mut dyn FnMut(i64, &mut ValueStore) -> Signal,
18+
run: &mut ThunkRunner<'runner>,
1719
) -> Signal;
1820

1921
#[derive(Clone, Copy)]

crates/taurus-core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
66
mod handler;
77
pub mod runtime;
8+
pub mod time;
89
pub mod types;
910
pub mod value;

0 commit comments

Comments
 (0)