| Name | Type | Env | Values | Default | Description |
|---|---|---|---|---|---|
| Env | string | ENV | prod, dev, test | prod | Server mode |
| RootDir | string | ROOT_DIR | Root dir | ||
| TmpDir | string | TMP_DIR | tmp | Temporary files dir | |
| NoLog | bool | NO_LOG | true | false | Disable std log output |
| SecretKey | string | SECRET_KEY | Envelope encryption key |
The
SECRET_KEYis used for encryptingplaintextsecrets such as API secrets. When you change this key you must reset the secrets.
Example
[order]
RootDir="/app"
TmpDir="/tmp"
SecretKey="!oeij9iUr.toAweija/oWeiJfh0a-wng1anglag/!sF5dSh#Gd"
Database
We currently support sqlite3, postgres and cockroach databases.
| Name | Type | Env | Values | Default | Description |
|---|---|---|---|---|---|
| Type | string | DB_TYPE | postgres,sqlite3 | Database type | |
| Dsn | string | DB_CONNECTION | Database url | ||
| Host | string | DB_HOST | Database host | ||
| Port | uint | DB_PORT | 1-65535 | Database port | |
| Name | string | DB_NAME | Database name | ||
| User | string | DB_USER | Database user | ||
| Pass | string | DB_PASS | database password | ||
| ConnMaxLifetime | time duration | DB_CONN_MAX_LIFETIME | “100s”,“10m” | Connection life time | |
| MaxIdleConns | int | DB_MAX_IDLE_CONNS | Max idle connections | ||
| MaxOpenConns | int | DB_MAX_OPEN_CONNS | Max open connections | ||
| ReadOnly | bool | DB_READ_ONLY | false | Read only mode | |
| Migrate | bool | DB_MIGRATE | false | Enable migrations |
If you use
dsnyou don’t need to specify databasetype,host,port,name,userorpass.
Migrations
Upon startup the system checks if there are any pending database schema migrations and applies them in sequence. If one of the migrations fail everything gets rolled back and the startup fails with details in its log output.
The
Migratesetting allows you to control automatic schema migrations. If you want toupdateorupgradethe system you cannot haveReadOnlymode and must setMigratetotrue.
Database opts
The opts setting allows you to set additional configuration parameters for the database.
| Name | Type | Env | Values | Default | Description |
|---|---|---|---|---|---|
| Set | string | Option setting | |||
| Val | string | Option value |
The options you can set depends on the database type and version you are using.
Example
sqlite3 database configuration.
[order.database]
type = "sqlite3"
name = "/storage/order.db"
migrate = true
[[order.database.opts]]
set = "foreign_keys"
val = "ON"
[[order.database.opts]]
set = "journal_mode"
val = "WAL"
The database gets created if it doesn’t exist.
Example
Postgres database configuration.
[order.database]
type = "postgres"
name = "order"
user = "postgres"
pass = "postgres"
host = "127.0.0.1"
port = 5432
migrate = true
If you have granted
create databasepermission to the dbuserthe database is created.
Example
Cockroach database configuration using dsn.
[order.database]
dsn = "cockroach://root@localhost:26257/order?sslmode=disable"
migrate = true
You must first create the
orderdatabase in cockroach or it will usedefaultdbinstead.
Backend
Server backend url (message bus).
| Name | Type | Env | Values | Default | Description |
|---|---|---|---|---|---|
| Url | string | BACKEND_URL | url | Url to backend server (message bus) |
Example
[order.backend]
url = "nats://172.16.172.16:4222"