Controllers

Controller

A Controller is a component that has oversees and has sovereignty over a specific part of the application. Dedicated controllers are implemented for managing the sequencing of operations, the handling of scopes, the execution flow, and the management of errors. Controllers essentially orchestrate and direct the process of interpreting the graph-based language, transforming it from a static structure into a dynamic, functioning program.

Master

The Master Controller, as is evident from its name, plays a pivotal role in coordinating and managing the execution of the code since it's the controller that has the role of managing the other ones.

It takes care of the following areas:

  1. Node Management: the controller creates, deletes, and maintains references to all the nodes in the system. It's also in charge of establishing and deleting the connections or edges between nodes.

  2. Execution Control: the controller determines the execution flow based on the graph structure. It's responsible for traversing the graph and invoking Walkers, which could involve in complex paths and cycles.

  3. Scope Management: the controller holds the values of variables that are accessible at each set of nodes. The controller manages these scopes and ensures they are correctly used and updated during execution.

  4. Error Handling: the controller handling invalid operations, incorrect graph structures, or runtime errors within a node.

  5. Interactivity: when run in interactive mode, the controller can accept commands from a command line interface (CLI), perform operations on the graph (like adding or removing nodes), and show the current state of the graph.

Graph Controller

This controller maintains the topology of the graph, which forms the skeleton of the program. It creates the structure within the program. The Graph Controller does not dictate how individual nodes behave, but it does define how they interact with one another, shaping the execution flow of the graph-based language. It checks for errors, manages nodes, do searches.

Walker

The Walker starts from a start node, and systematically moves through the graph by invoking the Executor of each node it encounters. If a node activates multiple subsequent nodes, the Waller Controller spawns additional Walkers to explore each path concurrently, ensuring all potential execution paths are covered

Execution Controller

The Execution Controller manages the execution of tasks in each node of the graph. Whether the tasks are synchronous or asynchronous, the Executor Controller handles them efficiently.

For synchronous tasks, it ensures that they are executed in the order they are received, maintaining the sequence of operations. For asynchronous tasks, it allows for non-blocking execution, meaning multiple tasks can be processed simultaneously without waiting for each other to finish.

The Execution Controller writes the results of each task into a scope that can be shared.

Scope Controller

The primary task of the Scope Controller is to manipulate the mapping between the scopes and the variables they contain. This is achieved through a hashing mechanism that guarantees quick and efficient lookup. The hash is generated by sorting the hashes of the nodes and concatenating them. This concatenated string is then hashed again to form a unique identifier for the specific scope. Of course, if it’s one is the scope of the node.

This design choice ensures that finding a scope given its related nodes becomes an operation with a complexity close to O(1). This efficiency is critical in a graph-based language where scopes could be numerous, and rapid retrieval is crucial for maintaining the overall performance of the system.

Error Controller

The Error Controller manages the Error Handler that steps in when an operation in the graph execution fails. It does so by catching the error, preserving the state of the program at the moment the error occurred, and providing meaningful feedback about what went wrong.

Last updated