Skip to content

Commit

Permalink
Enforce flags for rendering consumers and producers
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Coomber committed Nov 3, 2012
1 parent b1a707f commit 5bca4b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
@@ -1,5 +1,5 @@
.PHONY: samples

samples:
python rabbitmq_graphviz.py -d samples/tutorial.json -o samples/tutorial.dot -p
python rabbitmq_graphviz.py -d samples/tutorial.json -o samples/tutorial.dot -p -c
dot -Tpng samples/tutorial.dot > samples/tutorial.png
12 changes: 8 additions & 4 deletions rabbitmq_graphviz.py
Expand Up @@ -24,17 +24,21 @@ def render_queue(write, queue, render_consumers):
write(' color=transparent;')
write(' "Q_%s" [label="{||||}", fillcolor="red", shape="record"];' % escape_id(queue['name']))
write(' }\n')
write(' "C_%s" [label="C", fillcolor="#33ccff"];' % escape_id(queue['name']))
write(' "Q_%(name)s" -> "C_%(name)s"' % { 'name': escape_id(queue['name'])})

if render_consumers:
write(' "C_%s" [label="C", fillcolor="#33ccff"];' % escape_id(queue['name']))
write(' "Q_%(name)s" -> "C_%(name)s"' % { 'name': escape_id(queue['name'])})

def render_exchange(write, exchange, render_producers):
write(' subgraph cluster_X_%s {' % escape_id(exchange['name']))
write(' label="%s\\ntype=%s";' % (exchange['name'], exchange['type']))
write(' color=transparent;')
write(' "X_%s" [label="X", fillcolor="#3333CC", shape="ellipse"];' % escape_id(exchange['name']))
write(' }\n')
write(' "P_%s" [label="P", style="filled", fillcolor="#00ffff"];' % escape_id(exchange['name']))
write(' "P_%(name)s" -> "X_%(name)s";' % { 'name': escape_id(exchange['name']) })

if render_producers:
write(' "P_%s" [label="P", style="filled", fillcolor="#00ffff"];' % escape_id(exchange['name']))
write(' "P_%(name)s" -> "X_%(name)s";' % { 'name': escape_id(exchange['name']) })

def render_binding(write, binding):
write(' X_%s -> Q_%s [label="%s"];' % (escape_id(binding['source']), escape_id(binding['destination']), binding['routing_key']))
Expand Down

0 comments on commit 5bca4b4

Please sign in to comment.