Choreo.Lab.DSL.Dependency (Choreo v0.12.0)

Copy Markdown View Source

Experimental Livebook-friendly DSL for sketching software dependency graphs.

This Lab DSL compiles to the stable, pipe-first Choreo.Dependency builders and returns an ordinary %Choreo.Dependency{}. It is useful for quick architecture sketches, refactoring conversations, onboarding maps, and interview explanations of coupling between applications, modules, libraries, interfaces, and tests.

Examples

iex> import Choreo.Lab.DSL.Dependency
...> deps = dependency do
...>   core = cluster("Core")
...>   api = application("API Gateway")
...>   auth = module("Auth", cluster: core)
...>   contract = interface("Auth Behaviour")
...>   phoenix = library("Phoenix")
...>
...>   api ~> phoenix |> uses("HTTP stack")
...>   api ~> auth |> calls("validates token")
...>   auth ~> contract |> implements("implements callbacks")
...> end
iex> Enum.sort(Choreo.Dependency.nodes(deps))
[:api, :auth, :contract, :phoenix]

Edges can use generic, typed, or pipe-modified forms:

api ~> auth
api ~> auth |> calls("validates token")
edge api ~> phoenix, uses: "framework"
imports module_a ~> module_b, "alias/import"
dev app ~> test_lib, "test helper"

Summary

Types

cluster_decl()

@type cluster_decl() :: %{id: String.t(), opts: keyword()}

edge_decl()

@type edge_decl() :: %{from: Yog.node_id(), to: Yog.node_id(), opts: keyword()}

node_decl()

@type node_decl() :: %{id: Yog.node_id(), builder: atom(), opts: keyword()}

Functions

app(arg1 \\ nil, arg2 \\ nil, opts \\ [])

application(arg1 \\ nil, arg2 \\ nil, opts \\ [])

calls(arg1 \\ nil, arg2 \\ nil, opts \\ [])

cluster(arg1 \\ nil, arg2 \\ nil, opts \\ [])

component(arg1 \\ nil, arg2 \\ nil, opts \\ [])

contract(arg1 \\ nil, arg2 \\ nil, opts \\ [])

dependency(list)

(macro)

Builds a %Choreo.Dependency{} from a compact Lab DSL block.

dependency(opts, list)

(macro)

depends(arg1 \\ nil, arg2 \\ nil, opts \\ [])

depends_on(arg1 \\ nil, arg2 \\ nil, opts \\ [])

dev(arg1 \\ nil, arg2 \\ nil, opts \\ [])

group(arg1 \\ nil, arg2 \\ nil, opts \\ [])

implements(arg1 \\ nil, arg2 \\ nil, opts \\ [])

imports(arg1 \\ nil, arg2 \\ nil, opts \\ [])

inherits(arg1 \\ nil, arg2 \\ nil, opts \\ [])

interface(arg1 \\ nil, arg2 \\ nil, opts \\ [])

layer(arg1 \\ nil, arg2 \\ nil, opts \\ [])

lib(arg1 \\ nil, arg2 \\ nil, opts \\ [])

library(arg1 \\ nil, arg2 \\ nil, opts \\ [])

module(arg1 \\ nil, arg2 \\ nil, opts \\ [])

package(arg1 \\ nil, arg2 \\ nil, opts \\ [])

protocol(arg1 \\ nil, arg2 \\ nil, opts \\ [])

service(arg1 \\ nil, arg2 \\ nil, opts \\ [])

spec(arg1 \\ nil, arg2 \\ nil, opts \\ [])

taxonomy()

@spec taxonomy() :: %{
  clusters: [atom()],
  nodes: [atom()],
  edges: [atom()],
  modifiers: [atom()],
  options: [atom()]
}

Returns the vocabulary supported by the dependency DSL.

iex> taxonomy = Choreo.Lab.DSL.Dependency.taxonomy()
iex> :application in taxonomy.nodes
true
iex> :cluster in taxonomy.clusters
true
iex> :calls in taxonomy.edges
true

test_suite(arg1 \\ nil, arg2 \\ nil, opts \\ [])

uses(arg1 \\ nil, arg2 \\ nil, opts \\ [])

verbs()

@spec verbs() :: map()

Compatibility alias for taxonomy/0.