Webmachine hackers are familiar with a certain flowchart representing the decisions made during the processing of an HTTP request. Webmachine was designed as a practical executable form of that flowchart.
It has long bugged many of the Webmachine hackers that this relationship is one-way, though. Webmachine was made from the graph, but the graph wasn't made from Webmachine. I decided to change that in my evenings last week, while trying to take my mind off of Riak 1.0 testing.
This is a version of the HTTP flowchart that only a Webmachine
hacker could love. It's ugly and missing some information, but
the important part is that it's generated by
I've shared the code for generating this image in
branch of my webmachine fork. Make sure you
have Graphviz installed,
then checkout that branch and run
make graph && open
In addition to the PNG, you'll also find
docs/wdc_graph.dot if you prefer to render to some
If you'd really like to dig in, I suggest firing up an Erlang node
and looking at the output
If you've looked through
all, I think you'll recognize what's presented above: a list of
tuples, each one representing the decision named by the first
element, with the calls made to a resource module as the second
element, and the possible outcomes as the third element.
wdc_graph:dot/2 to convert those tuples to a DOT
There are a few holes in the generation. Some response codes are
reached by decisions spread across the graph, causing long arrows
to cross confusingly. The edges between decisions aren't labeled
with the criteria for following them. Some resource calls are
left out (like those made
webmachine_decision_core:respond/1 and the
response body producers and encoders). It's good to have a nice
list for future tinkering.
Post Copyright © 2011 Bryan Fink