Class ReactiveScriptEngine

java.lang.Object
com.soulfiremc.server.script.ReactiveScriptEngine

public final class ReactiveScriptEngine extends Object

Reactive execution engine for visual scripts. Uses Project Reactor for proper fan-in synchronization and parallel branch execution.

Key features:

  • Fan-in: Waits for all upstream DATA edges before executing a node
  • Parallelism: Independent branches execute concurrently via Flux.flatMap
  • Dynamic routing: Follows exec output ports whose IDs appear in node outputs
  • Self-driving loops: Loop nodes call back into the engine via NodeRuntime.executeDownstream
  • Error routing: Nodes with exec_error ports route errors; others stop the branch
  • Muted bypass: Muted nodes pass execution context through unchanged
  • Per-invocation isolation: Each trigger creates its own ExecutionRun
  • Constructor Details

    • ReactiveScriptEngine

      public ReactiveScriptEngine()
  • Method Details

    • executeFromTrigger

      public reactor.core.publisher.Mono<Void> executeFromTrigger(ScriptGraph graph, String triggerNodeId, ReactiveScriptContext context, Map<String, NodeValue> eventInputs)
      Executes a script starting from a specific trigger node. Used by ScriptTriggerService when an event fires.
      Parameters:
      graph - the script graph
      triggerNodeId - the trigger node to start from
      context - the reactive execution context
      eventInputs - inputs from the triggering event
      Returns:
      a Mono that completes when execution finishes
    • execute

      public reactor.core.publisher.Mono<Void> execute(ScriptGraph graph, InstanceManager instance, ScriptEventListener eventListener)
      Executes the full graph (for testing/one-shot execution).
      Parameters:
      graph - the script graph to execute
      instance - the SoulFire instance
      eventListener - listener for execution events
      Returns:
      a Mono that completes when the script finishes
    • getNode

      public ScriptNode getNode(String type)
      Gets a registered node by type.
      Parameters:
      type - the node type identifier
      Returns:
      the node implementation, or null if not found
    • getRegisteredNodeTypes

      public List<String> getRegisteredNodeTypes()
      Returns all registered node types.
      Returns:
      list of registered node type identifiers