Experimental Livebook-friendly DSL for sketching sequence diagrams.
Unlike most Choreo Lab DSLs, sequence diagrams are primarily ordered event
streams rather than static topology. This DSL still uses participant
constructors for nouns, but message, activation, note, and fragment statements
compile to ordered Choreo.Sequence events.
Examples
iex> import Choreo.Lab.DSL.Sequence
...> diagram = sequence do
...> user = actor("User")
...> api = participant("API")
...> db = participant("Database")
...>
...> user ~> api |> call("GET /accounts")
...> activate api
...> api ~> db |> call("SELECT accounts")
...> reply db ~> api, "rows"
...> deactivate api
...> reply api ~> user, "200 OK"
...> end
iex> Choreo.Sequence.participants(diagram)
[:user, :api, :db]
iex> Choreo.Sequence.messages(diagram) |> Enum.map(& &1[:label])
["GET /accounts", "SELECT accounts", "rows", "200 OK"]Message edges can use pipe modifiers, typed constructors, or generic edge:
user ~> api |> call("GET /accounts")
async api ~> worker, "enqueue job"
reply db ~> api, "rows"
edge api ~> db, async: "fire and forget"Notes and fragments are event statements:
over api, "Validates bearer token"
between api, db, "Tenant scoped query"
loop "retry up to 3 times" do
api ~> worker |> async("process job")
end
alt "authorized" do
api ~> db |> call("read tenant")
otherwise "denied"
api ~> user |> reply("403")
end
Summary
Functions
Builds a %Choreo.Sequence{} from a compact Lab DSL block.
Returns the vocabulary supported by the sequence DSL.
Compatibility alias for taxonomy/0.
Types
Functions
Builds a %Choreo.Sequence{} from a compact Lab DSL block.
@spec taxonomy() :: %{ participants: [atom()], messages: [atom()], events: [atom()], notes: [atom()], fragments: [atom()], modifiers: [atom()], options: [atom()] }
Returns the vocabulary supported by the sequence DSL.
This is meant as a lightweight Livebook discovery helper when autocomplete is not enough.
iex> taxonomy = Choreo.Lab.DSL.Sequence.taxonomy()
iex> :actor in taxonomy.participants
true
iex> :reply in taxonomy.messages
true
iex> :loop in taxonomy.fragments
true
@spec verbs() :: map()
Compatibility alias for taxonomy/0.