package api import ( "context" "git.sendico.io/tech/sxchnge/shared/database" "git.sendico.io/tech/sxchnge/shared/logging" ) type ConfigProvider interface{ SharedConfig() *Config } type ConfigFactory func() ConfigProvider // Bootstrap opens process-owned resources. Its cleanup is called once even if // installation fails. On error, bootstrap must return cleanup or clean its own // resources before returning, never both. type Bootstrap func(context.Context, mlogger.Logger, *Config, db.Factory) (*Dependencies, func(context.Context) error, error) type RuntimeConfig struct { Name string ConfigFactory ConfigFactory Bootstrap Bootstrap Versions map[string]Installer } func (cfg RuntimeConfig) RuntimeName() string { if cfg.Name == "" { return "product" } return cfg.Name } func (cfg RuntimeConfig) NewConfig() ConfigProvider { if cfg.ConfigFactory != nil { return cfg.ConfigFactory() } return &Config{} }