package
0.0.0-20240814010835-9fc48a241e25
Repository: https://github.com/surahman/ftex.git
Documentation: pkg.go.dev

# README

Postgres

Configuration loading is designed for containerization in mind. The container engine and orchestrator can mount volumes (secret or regular) as well as set the environment variables as outlined below.

You may set configurations through both files and environment variables. Please note that environment variables will override the settings in the configuration files. The configuration files are all expected to be in YAML format.


Table of contents


File Location(s)

The configuration loader will search for the configurations in the following order:

LocationDetails
/etc/FTeX.conf/The etc directory is the canonical location for configurations.
$HOME/.FTeX/Configurations can be located in the user's home directory.
./configs/The config folder in the root directory where the application is located.
Environment variablesFinally, the configurations will be loaded from environment variables and override configuration files

Configuration File

The expected file name is PostgresConfig.yaml. All the configuration items below are required unless specified otherwise.

NameEnvironment Variable KeyTypeDescription
AuthenticationPOSTGRES_AUTHENTICATIONParent key for authentication information.
↳ username.USERNAMEstringUsername for Postgres session login.
↳ password.PASSWORDstringPassword for Postgres session login.
ConnectionPOSTGRES_CONNECTIONParent key for connection information.
↳ database.DATABASEstringDatabase name.
↳ host.HOSTstringHostname or IP address.
↳ maxConnectionAttempts.MAXCONNECTIONATTEMPTSintNumber of times to attempt a connection to the database using Binary Exponential Backoff.
↳ timeout.TIMEOUTintConnection timeout in seconds.
↳ port.PORTuint16Host port.
PoolPOSTGRES_POOLParent key for connection pool information.
↳ healthCheckPeriod.HEALTHCHECKPERIODtime.DurationSeconds (min=5) between health checks for each connection in the pool.
↳ maxConns.MAXCONNSint32Maximum connections (min=4) to retain in the connection pool.
↳ minConns.MINCONNSint32Minimum connections (min=4) to retain in the connection pool.

Example Configuration File

authentication:
  username: postgres
  password: postgres
connection:
  database: ft-ex-db
  host: 127.0.0.1
  maxConnectionAttempts: 5
  port: 6432
  timeout: 5
pool:
  healthCheckPeriod: 30s
  maxConns: 8
  minConns: 4

Example Environment Variables

export POSTGRES_AUTHENTICATION.USERNAME=admin
export POSTGRES_AUTHENTICATION.PASSWORD=root

Design Documentation

The technology selection case study and table schema design documentation can be found here.