Writing a Process
This example is a Process that just adds 1 to its argument and returns it. The name of the function (or manifest) becomes the Process’s type name.
use juiz_sdk::prelude::*;
#[juiz_process]fn increment_process(arg1: i64) -> JuizResult<Capsule> { log::trace!("increment_process({:?}) called", arg1); return Ok(jvalue!(arg1 + 1).into());}A function marked with the #[juiz_process] macro becomes the body of the Process.
It can take several arguments, of types such as i64, f64, bool, String, Value and Vec<Value>. Parameter names become the argument names as is.
#include "juiz/juiz.h"
juiz::Value manifest() { return ProcessManifest{"increment_process_cpp"} .add_int_arg("arg1", "test_argument", 1) .into_value();}
std::optional<int64_t> increment_process(juiz::CapsuleMap cm) { auto a = cm.get_int("arg1"); return a + 1;}
PROCESS_FACTORY(manifest, increment_process);In C++ you write the manifest (the type name and argument definitions) yourself and export it with PROCESS_FACTORY.
from juiz import *
@juiz_processdef increment_process(arg1: int = 1) -> int: return arg1 + 1Just add the @juiz_process decorator to make it a Process. Define your own data types as dataclasses, and convert outputs to dicts with asdict before returning them.
Running it on its own
Section titled “Running it on its own”Give the built file with --process, and instantiate and run it with -e.
juiz --process target/debug/libincrement_process.so -l rust -e -1 -d-lis the language (rust/cpp/python, defaultrust)-einstantiates one loaded Process and runs it with its default arguments-1creates one instance per loaded module-dstarts the HTTP broker after running and keeps waiting