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
parsing webmachine_decision_core.erl
.
I've shared the code for generating this image in
the gen-graph
branch of my webmachine fork. Make sure you
have Graphviz installed,
then checkout that branch and run make graph && open
docs/wdc_graph.png
.
In addition to the PNG, you'll also find
a docs/wdc_graph.dot
if you prefer to render to some
other format.
If you'd really like to dig in, I suggest firing up an Erlang node
and looking at the output
of wdc_graph:parse("src/webmachine_decision_core.erl")
:
If you've looked through webmachine_decision_core
at
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.
Call wdc_graph:dot/2
to convert those tuples to a DOT
file.
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
from webmachine_decision_core:respond/1
and the
response body producers and encoders). It's good to have a nice
list for future tinkering.
Categories: Development Erlang Webmachine
Post Copyright © 2011 Bryan Fink