Experimental Livebook-friendly DSL for sketching infrastructure diagrams.
This module is an incubating Lab syntax layer over the stable, pipe-first
Choreo infrastructure builders. It returns a normal %Choreo{} system, so
the result can be rendered and analysed with the same functions as any other
Choreo graph.
The DSL is intentionally strict about references: bind nodes to variables and reuse those variables in edges. Typos in labels render as written; typos in variable names fail during macro expansion.
Examples
iex> import Choreo.Lab.DSL.Infrastructure
...> system = infrastructure do
...> client = user("API Client")
...> api = gateway("API Gateway")
...> redis = cache("Redis", kind: :redis)
...> db = database("Postgres", kind: :postgres)
...>
...> client ~> api
...> api ~> redis |> on("checks quota")
...> edge api ~> db, with: "reads/writes"
...> end
iex> system.graph.nodes[:api].label
"API Gateway"
iex> system.graph.nodes[:redis].node_type
:cache
iex> system.edge_meta |> Map.values() |> Enum.map(& &1.label) |> Enum.sort()
[nil, "checks quota", "reads/writes"]Supported cluster constructors:
Supported node constructors:
user/1,client/1gateway/1,load_balancer/1,lb/1service/1compute/1database/1,db/1managed_db/1cache/1queue/1storage/1,object_store/1internet/1network/1,external/1node/1,custom/1
Cluster variables can be used in parent: and node cluster: options:
prod = vpc("Production VPC")
private = private_subnet("Private Subnet", parent: prod)
api = service("API", cluster: private)Edge labels can use either pipe modifiers or the explicit edge form:
api ~> db |> on("reads")
api ~> db |> label("reads")
edge api ~> db, "reads"
edge api ~> db, label: "reads"
edge api ~> db, with: "reads"
Summary
Functions
Builds a %Choreo{} infrastructure sketch from a compact Lab DSL block.
Returns the vocabulary supported by the infrastructure DSL.
Compatibility alias for taxonomy/0.
Types
@type edge_decl() :: %{from: Yog.node_id(), to: Yog.node_id(), opts: keyword()}
@type node_decl() :: %{id: Yog.node_id(), builder: atom(), opts: keyword()}
Functions
Builds a %Choreo{} infrastructure sketch from a compact Lab DSL block.
@spec taxonomy() :: %{ clusters: [atom()], nodes: [atom()], edges: [atom()], modifiers: [atom()], options: [atom()] }
Returns the vocabulary supported by the infrastructure DSL.
This is meant as a lightweight Livebook discovery helper when autocomplete is not enough.
iex> taxonomy = Choreo.Lab.DSL.Infrastructure.taxonomy()
iex> :vpc in taxonomy.clusters
true
iex> :service in taxonomy.nodes
true
iex> :~> in taxonomy.edges
true
iex> :on in taxonomy.modifiers
true
@spec verbs() :: %{ clusters: [atom()], nodes: [atom()], edges: [atom()], modifiers: [atom()], options: [atom()] }
Compatibility alias for taxonomy/0.