DatabaseConnection assists in setting up a database connection. It accepts the database properties and a new writer for the given component. If we're running in monolith mode with a global connection pool configured then we will return that connection, along with the global writer, effectively ignor
(dbProperties *config.DatabaseOptions, writer sqlutil.Writer)
| 262 | // have a BaseDendrite and just want a connection with the supplied config |
| 263 | // without any pooling stuff. |
| 264 | func (b *BaseDendrite) DatabaseConnection(dbProperties *config.DatabaseOptions, writer sqlutil.Writer) (*sql.DB, sqlutil.Writer, error) { |
| 265 | if dbProperties.ConnectionString != "" || b == nil { |
| 266 | // Open a new database connection using the supplied config. |
| 267 | db, err := sqlutil.Open(dbProperties, writer) |
| 268 | return db, writer, err |
| 269 | } |
| 270 | if b.Database != nil && b.DatabaseWriter != nil { |
| 271 | // Ignore the supplied config and return the global pool and |
| 272 | // writer. |
| 273 | return b.Database, b.DatabaseWriter, nil |
| 274 | } |
| 275 | return nil, nil, fmt.Errorf("no database connections configured") |
| 276 | } |
| 277 | |
| 278 | // AppserviceHTTPClient returns the AppServiceInternalAPI for hitting the appservice component over HTTP. |
| 279 | func (b *BaseDendrite) AppserviceHTTPClient() appserviceAPI.AppServiceInternalAPI { |
no test coverage detected