Documentation
¶
Overview ¶
Package config is an adapter which allows users to write a yaml configuration file and allow the caweb to instantiate different components, from the adapter or use cases layers, using those configuration settings. These settings may be versioned and maintained by migrations later. However, the parsed and validated configurations should be passed to their ultimate components as a series of individual params (for the mandatory items) and a series of functional options (for the optional items), so they may be accumulated and validated in another (possibly non-exorted) config struct (or directly in the relevant end-component such as a UseCase instance). This design decision causes a bit of redundancy in favor of a defensive solution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cars ¶
type Cars struct { // OldParkingDelay indicates the amount of delay that an old // parking method should incur. OldParkingDelay *time.Duration `yaml:"old-parking-method-delay"` }
Cars contains the configuration settings for the cars use cases.
type Config ¶
Config contains all settings which are required by different parts of the project such as adapters or use cases. It is preferred to implement Config with primitive fields or other structs which are defined in this package, not models or structs which are defined in other layers, so the configuration can be versioned and kept intact while other layers can change freely. If two versions of the Config struct were implemented, the newer version may embed/depend on the older version (which is freezed).
func Load ¶
Load function loads, validates, and normalizes the configuration file and returns its settings as an instance of the Config struct.
func (*Config) ValidateAndNormalize ¶
ValidateAndNormalize validates the configuration settings and returns an error if they were not acceptable. It can also modify settings in order to normalize them or replace some zero values with their expected default values (if any).
type Database ¶
type Database struct { Host string // domain name or IP address of the DBMS server Port int // port number of the DBMS server Name string // database name, like caweb1_0_0 Role string // role/username for connecting to the database PassFile string `yaml:"pass-file"` // path of the password file }
Database contains the database related configuration settings.