Closed HariSekhon closed 1 year ago
D2 is a library too, so you can do that in Go (which has loops), and that'd be the equivalent of Python's Diagrams. See this post for more: https://terrastruct.com/blog/post/generate-diagrams-programmatically/
With text, there's no loops of course, as in all declarative languages. I think this feature would help though (once implemented): https://github.com/terrastruct/d2/issues/742
Is it possible to generate objects and connections programmatically instead of having to explicitly declare each one?
Compare these two pieces of code from D2 vs Python diagrams module:
It then gets worse... because I then add 12 HBase nodes which underpin the OpenTSDB cluster...
... and then want a cartesian production of connections between each of the 15 OpenTSDB nodes vs the 12 HBase nodes... so 180 connections - programmatically in Python that's just a nested for loop iteration, but I can't see how to do this efficiently in D2.