Closed gp-mlezotte closed 2 years ago
!ref
is designed to be used with the workspace extension feature, so any elements should have already been defined inside an enterprise in the base workspace. Can you provide an example of what you're trying to do?
My original thought was that I might be able to declutter some of my DSL files by migrating the perspectives into separate files themselves. After thinking it through a little more, I came to the conclusion that maybe I was trying to separate it out a little too much, and that it might not be worth the effort given that it seems like I would need to add an identifier for everything, including relationships. I would love it if I could just "layer" a perspective file on top of a structure file without having to do anything special in the structure file. I may revisit this in the future... it was mainly an exercise to help me understand some functionality in Structurizr.
Maybe a couple of examples will help to illustrate where I was getting the error.
This DSL will work fine:
workspace "Test" "Description" {
model {
testSystem = softwareSystem "Test System"
!ref testSystem {
container "Test Container"
}
}
}
This will throw the error I mentioned above:
workspace "Test" "Description" {
model {
enterprise "Test Company" {
testSystem = softwareSystem "Test System"
!ref testSystem {
container "Test Container"
}
}
}
}
The only difference is that in the second example, the definitions and !ref
are wrapped in an enterprise
.
This will work though:
workspace "Test" "Description" {
model {
enterprise "Test Company" {
testSystem = softwareSystem "Test System"
}
!ref testSystem {
container "Test Container"
}
}
}
And the software system is still rendered inside the enterprise.
I would love it if I could just "layer" a perspective file on top of a structure file without having to do anything special in the structure file.
You could do this via the plugin mechanism:
The DSL is a just a wrapper for the Structurizr for Java library, so you have the full power of that at your disposal.
I didn't think to move the !ref
outside of the enterprise
. This is exactly what I was looking for. That's a great suggestion for using the Java library as well. I'm a .NET developer by trade, but it's looking like I'll have to get into Java a little more to take full advantage of Structurizr. Thanks so much!
You can also do something similar with the .NET library, although you'd need to convert the DSL to JSON (with the Structurizr CLI) as a first step -> https://github.com/structurizr/dsl/tree/master/docs/cookbook/dsl-and-code#other-languages
Thanks again! That looks like it could be very useful as well. I really appreciate all the extensibility options!
I've been experimenting with using
!ref
with!include
to make my DSL files cleaner and more focused. I had a lot of trouble at first getting it working, and was always receiving the following error in Structurizr Lite:I eventually tried simplifying my DSL and removing the
enterprise
wrapper. When I did this, the!ref
s started working.Is it possible to use
!ref
withinenterprise
? If not, could this functionality be added or are there any suggestions for working around it? If it helps, I've been using non-hierarchical identifiers, but plan to switch to hierarchical identifiers in the future.