4 releases

0.1.0 Apr 26, 2022
0.0.3 Apr 17, 2022
0.0.2 Apr 8, 2022
0.0.1 Apr 8, 2022

#56 in #control-flow


Used in conflagrate

MIT license

59KB
1K SLoC

🔥 Conflagrate

Build applications from control flow graphs, rather than the other way around.

  1. Define your application flow with a Graphviz diagram
  2. Write the code for each node as a function
  3. Run

Conflagrate is a framework for building applications structured as the control flow graphs they end up becoming anyway.

Build the pieces of your application as self-contained nodes. Arrange and rearrange control flow logic as your needs mature and change without having to go back and rewrite the glue code connecting your components.

🔨 Build the Graph

Define your application control flow with a graph.

conflagrate::graph!{

    digraph MessageHandlerGraph {
        listen[label="Listen on a Socket for a Message", type=Listen, start=true];
        handle_message[label="Handle the Message", type=HandleMessage];

        listen -> handle_message;  // Handle the message
        listen -> listen;  // Listen for the next message
    }

}

💻 Implement the Nodes

Write a function for each type of node in your application.

use conflagrate::nodetype;

#[nodetype]
async fn Listen(interface: &SocketInterface) -> String {
    interface.receive().await
}

#[nodetype]
async fn HandleMessage(message: String, logger: &Logger) {
    logger.log(message);
}

🚀 Run

Run the application.

fn main() {
    MessageHandlerGraph::run(());
}

Dependencies

~5–16MB
~196K SLoC