Skip to main content

Module builder

Module builder 

Source
Expand description

Fluent builders for DrasiLib and components Fluent builders for DrasiLib and its components.

This module provides the builder pattern for constructing DrasiLib instances and their components in a type-safe, ergonomic way.

§Overview

  • DrasiLibBuilder - Main builder for creating a DrasiLib instance
  • Query - Builder for query configurations

§Plugin Architecture

Important: drasi-lib has ZERO awareness of which plugins exist. Sources and reactions are created externally as fully-configured instances implementing Source and Reaction traits, then passed to DrasiLibBuilder via with_source() and with_reaction().

§Examples

§Basic Usage with Pre-built Instances

use drasi_lib::{DrasiLib, Query};

// Source and reaction instances are created externally by plugins
// Ownership is transferred to DrasiLib when added
// let my_source = my_source_plugin::create(...);
// let my_reaction = my_reaction_plugin::create(...);

let core = DrasiLib::builder()
    .with_id("my-server")
    // .with_source(my_source)      // Ownership transferred
    // .with_reaction(my_reaction)  // Ownership transferred
    .with_query(
        Query::cypher("my-query")
            .query("MATCH (n:Person) RETURN n")
            .from_source("events")
            .build()
    )
    .build()
    .await?;

core.start().await?;

Structs§

DrasiLibBuilder
Fluent builder for creating DrasiLib instances.
Query
Fluent builder for query configurations.