Skip to main content

Models

Models are the elements that exist throughout the execution of a program, extending beyond the lifetime of treatments. In particular, they allow interaction with the outside of a program. Models can be defined and configured, then instantiated in treatment declarations.

Definition

A model is defined using a base model and parameters.

model MyDatabase(const max: u32 = 5) : SqlPool
{
min_connections = 1
max_connections = max
url = "postgresql://my-user@my-server:4321/my_database"
}

Inheritance

A model being defined on a base model, it inherits the characteristics, and any treatment requiring a model of the base type can accept any model defined on it.

treatment myApp()
model database: MyDatabase(max=3)
{
userData[database=database]()

/* … */
}

treatment userData[database: SqlPool]()
{
/* … */
}