Skip to main content

run_module_with_setup

Function run_module_with_setup 

Source
pub async fn run_module_with_setup<M, C, F, FE, Fut, FSetup, FutSetup>(
    socket_path: impl AsRef<Path>,
    module_id: &str,
    module_name: &str,
    version: &str,
    cli_spec: CliSpec,
    rpc_methods: &[&str],
    event_types: Vec<EventType>,
    dispatch: F,
    on_event: FE,
    setup: FSetup,
    db: Arc<dyn Database>,
    data_dir: &Path,
) -> Result<(), ModuleError>
where F: Fn(InvocationMessage, InvocationContext, &M, &C) -> InvocationResultMessage, FE: Fn(EventMessage, &M, &InvocationContext) -> Fut, Fut: Future<Output = Result<(), ModuleError>> + Send, FSetup: Fn(Arc<dyn NodeAPI>, Arc<dyn Database>, &Path) -> FutSetup, FutSetup: Future<Output = Result<(M, C), ModuleError>> + Send,
Expand description

Run a module where (module, cli) are created after connect.

Use when the module depends on NodeAPI (e.g. datum creates DatumServer with node_api). The setup receives (node_api, db, data_dir) and returns (module, cli).