Event pipeline

Creation of a single execution path with multiple nodes

The goal is to join a set of nodes together to form an execution graph that processes an event in predictable order. The execution graph has a single path a pipline node is invoked after a parent node has processed an event.

The @OnEvent annotation marks a method to be included in the execution graph. The method will be invoked when all of its dependent nodes on the execution path have processed the event. Event processing includes @OnEvent and @EventHandler annotated methods of parents.

Only methods marked with @OnEvent will be included in the execution graph

A valid OnEvent method has no arguments with an optional boolean return type. The boolean return indicates whether this node is "dirty" and event notification should continue, change notifications are discussed later.

Example

This example defines a PipelineNode that is dependent upon a DataEventHandler. The DataEventHandler processes DataEvent's as an event handler.

The pipeline example code is located here.

The update method will be invoked by the SEP in topological order after the DataHandler has processed an incoming event. We define the graph imperatively using a builder class, further discussion on builders is in the graph building section.

Node class

The PipelineNode class declares a dependency to its parent, DataEventHandler (handler). The @OnEvent annotation requires this method to be invoked after handler has complete processing the incoming event. See here for discussion on node ordering.

public class PipelineNode {

    private final DataEventHandler handler;

    public PipelineNode(DataEventHandler handler) {
        this.handler = handler;
    }
    
    @OnEvent
    public void update(){}
}

SEPConfig builder

A pipeline is defined with two nodes, the PipelineNode is a child of the DataEventHandler node.

public class Builder extends SEPConfig {

    @Override
    public void buildConfig() {
        DataEventHandler handler = new DataEventHandler();
        PipelineNode node = new PipelineNode(handler);
        addNode(handler);
        addNode(node);
    }

}

Generated SEP

The generated SEP, implements a dispatch method invoking the execution path in topological order. As expected dataEventHandler_1 processes the event before pipelineNode_3 is notified of the event wave.

public class SampleProcessor implements EventHandler, BatchHandler, Lifecycle {

  //Node declarations
  private final DataEventHandler dataEventHandler_1 = new DataEventHandler();
  private final PipelineNode pipelineNode_3 = new PipelineNode(dataEventHandler_1);
  
  public SampleProcessor() {}

//omitted code for clarity

  public void handleEvent(DataEvent typedEvent) {
    //Default, no filter methods
    dataEventHandler_1.handleEvent(typedEvent);
    pipelineNode_3.update();
    //event stack unwind callbacks
    afterEvent();
  }

}

Generated ong

The graphical representation of this execution graph as generated by Fluxtion ESC:

As described in structured processing, the elements in the image are consistent with the generated code. For example the variable name of the PipelineNode is pipelineNode_3 in both the image and the generated SEP.

An execution is path is formed by the ESC, the nodes are methods on that path. We mark a method for inclusion in the graph using the @OnEvent annotation. Any OnEvent method will be invoked when all of its dependent nodes on the execution path have executed their respective event handling methods. Event handling methods include both @OnEvent and @EventHandler methods.

Any method marked with @OnEvent should be a no arg method, with an optional boolean return. The boolean return value indicates if this node has updated after processing the notification.

Last updated