pub struct EngineBuilder { /* private fields */ }Expand description
Builds an Engine from definitions: functions registered on a
Registry, the workflows, and the config. build fails
if any workflow is rejected, with every rejected definition’s issues.
A host that quarantines, and runs the workflows that compile, uses a
Compiler instead.
use dataflow_rs::Engine;
use dataflow_rs::program::IssueCode;
use serde_json::json;
let issues = Engine::builder()
.workflow_json(&json!({"id": "w", "tasks": [
{"id": "t", "function": {"name": "fetch"}}
]}))
.build()
.unwrap_err();
assert_eq!(issues[0].code, IssueCode::UnknownFunction);Implementations§
Source§impl EngineBuilder
impl EngineBuilder
Sourcepub fn registry(self, registry: Registry) -> Self
pub fn registry(self, registry: Registry) -> Self
Replaces the registry, and every function registered so far with it.
Sourcepub fn register<F: Function>(self, name: &str, f: F) -> Self
pub fn register<F: Function>(self, name: &str, f: F) -> Self
Registers f under name on the registry, as
Registry::register, whose panics it shares.
Sourcepub fn layer<L: CallLayer>(self, l: L) -> Self
pub fn layer<L: CallLayer>(self, l: L) -> Self
Adds a layer around every host call on the registry, as
Registry::layer: the first added is the outermost.
Sourcepub fn options(self, options: CompileOptions) -> Self
pub fn options(self, options: CompileOptions) -> Self
Sets the options the workflows compile with.
Sourcepub fn config(self, config: EngineConfig) -> Self
pub fn config(self, config: EngineConfig) -> Self
Sets the engine’s config.
Sourcepub fn workflow(self, def: WorkflowDef) -> Self
pub fn workflow(self, def: WorkflowDef) -> Self
Adds a parsed definition.
Sourcepub fn workflow_json(self, raw: &Value) -> Self
pub fn workflow_json(self, raw: &Value) -> Self
Adds a definition to parse with ParseOptions::default, the compat
reader on. One parse refuses makes build fail with
its parse issues, and one it reads but the compile rejects with its
parse issues, then its compile issues.
Sourcepub fn workflow_json_owned(self, raw: Value) -> Self
pub fn workflow_json_owned(self, raw: Value) -> Self
Adds an owned definition, avoiding the compatibility reader’s copy.
Otherwise identical to Self::workflow_json.
Sourcepub fn build(self) -> Result<Engine, Vec<Issue>>
pub fn build(self) -> Result<Engine, Vec<Issue>>
Compiles every definition and links them into the engine’s program.
§Errors
Every issue of every definition that parse or
compile_one rejected, in
input order, a rejected definition’s parse issues before its
compile issues. On success the other issues are dropped: a host that
wants them calls Compiler::check.