mermaid-js / zenuml-core

The ZenUML renderer
https://embed.zenuml.com
MIT License
31 stars 8 forks source link

RFC: Duration Constraint #58

Open MrCoder opened 1 year ago

MrCoder commented 1 year ago

Duration Constraint

A constraint on a duration.

Notion

A duration constraint on a sequence diagram may be show by drawing a vertical line with open arrowheads at both ends between the vertical position of two events. An expression for the duration is placed in braces over the center of the arrow. The constraint may also be shown as a text expression in braces.

image Source: https://www.oreilly.com/api/v2/epubs/0321245628/files/0321245628_ch14lev1sec193_image01.jpeg

MrCoder commented 1 year ago

Proposed DSL

// {<1sec.}
"caller:Phone" -> "exchange:PBX": lift receiver
// {<10 sec.}
"exchange:PBX" -> "caller:Phone": dial tone
"caller: Phone" -> "exchange:PBX": dial digit r=duration
...
// [duration] {<5sec.}
"caller:Phone" -> "exchange:PBX": route
"exchange:PBX" -> "caller:Phone": ringing tone

Explanation on the DSL:

  1. the labels like a = now only add noise so are all omitted.
  2. Use a special comment for a message to specify the duration: 2.1. If it is a sync message draw the line near to the receiver's execution bar; 2.2 If it is an async message draw the line near to the sender's lifeline from the commented message to the first message sent to it.
  3. {r < 10 ms } is not represented in the DSL. It can be either in the message or comment.
  4. Use // [duration] to draw the message pointing downwards