NewBaseApp creates and returns a new BaseApp instance configured with the provided arguments. To initialize the app, you need to call `app.Bootstrap()`.
(config BaseAppConfig)
| 197 | // |
| 198 | // To initialize the app, you need to call `app.Bootstrap()`. |
| 199 | func NewBaseApp(config BaseAppConfig) *BaseApp { |
| 200 | app := &BaseApp{ |
| 201 | settings: newDefaultSettings(), |
| 202 | store: store.New[string, any](nil), |
| 203 | cron: cron.New(), |
| 204 | subscriptionsBroker: subscriptions.NewBroker(), |
| 205 | config: &config, |
| 206 | } |
| 207 | |
| 208 | // apply config defaults |
| 209 | if app.config.DBConnect == nil { |
| 210 | app.config.DBConnect = DefaultDBConnect |
| 211 | } |
| 212 | if app.config.DataMaxOpenConns <= 0 { |
| 213 | app.config.DataMaxOpenConns = DefaultDataMaxOpenConns |
| 214 | } |
| 215 | if app.config.DataMaxIdleConns <= 0 { |
| 216 | app.config.DataMaxIdleConns = DefaultDataMaxIdleConns |
| 217 | } |
| 218 | if app.config.AuxMaxOpenConns <= 0 { |
| 219 | app.config.AuxMaxOpenConns = DefaultAuxMaxOpenConns |
| 220 | } |
| 221 | if app.config.AuxMaxIdleConns <= 0 { |
| 222 | app.config.AuxMaxIdleConns = DefaultAuxMaxIdleConns |
| 223 | } |
| 224 | if app.config.QueryTimeout <= 0 { |
| 225 | app.config.QueryTimeout = DefaultQueryTimeout |
| 226 | } |
| 227 | |
| 228 | app.initHooks() |
| 229 | app.registerBaseHooks() |
| 230 | |
| 231 | return app |
| 232 | } |
| 233 | |
| 234 | // initHooks initializes all app hook handlers. |
| 235 | func (app *BaseApp) initHooks() { |
searching dependent graphs…