The DSL
The server reads a .dsl file as Kotlin code made of calls:
name(arguments) { statements }
The arguments and the block are each optional, so these are all calls:
kotlin()
flat { }
pkg("api") { }
Arguments
An argument is a string, a number, a name, a dotted name or another call, and it can be named:
post("/orders", auth = true) // a string, and a named argument
replicas(3) // a number
level(STRICT) // a name
level(Level.STRICT) // a dotted name
retry(backoff(seconds = 1.5), times = 3) // another call
| Value | Written as |
|---|---|
| String | "text", with escapes and ${...} templates, or """text""" |
| Number | 3, 1_000, 0xFF, 1.5 |
| Boolean | true, false |
| Null | null |
| Name | STRICT |
| Dotted name | Level.STRICT |
| Call | backoff(seconds = 1.5) |
Blocks and statements
A block holds statements, and a statement is a call. Statements are separated by a line break or by ;:
service("orders") {
replicas(3); region("eu-west")
routes {
get("/orders")
}
}
Comments
// A comment to the end of the line
/* A comment
of more lines */
What the syntax does not say
Which functions there are, what they take and where they may stand is up to the DSL, not to the syntax. Nothing in the server is about one DSL: it knows no function names, and highlights, outlines and checks any file in this syntax. What it knows of a DSL comes from the schema of that DSL, if the project has one.
samples/example.dsl, the
architecture rules of a Maven build, is one such DSL, and
samples/.dsl/example.json is its
schema.