// Port on which to run the service.
configurable int port = 8080;

//`configurable string password = ?;`
//
// This specifies that the password must be supplied in a configuration file.

Configurable variables

A module-level variable can be declared as configurable. The initializer of a configurable variable can be overridden at runtime (e.g., by a TOML file). A variable for which a configuration is required can use an initializer of ?. The type of a configurable variable must be a subtype of anydata.

For more information, see Making Ballerina Programs Configurable.

configurable int port = 8080;

Port on which to run the service.

configurable string password = ?;

This specifies that the password must be supplied in a configuration file.

bal run configurable_variables.bal