MCPcopy Create free account
hub / github.com/daodst/chat / DatabaseConnection

Method DatabaseConnection

setup/base/base.go:264–276  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

262// have a BaseDendrite and just want a connection with the supplied config
263// without any pooling stuff.
264func (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.
279func (b *BaseDendrite) AppserviceHTTPClient() appserviceAPI.AppServiceInternalAPI {

Callers 13

NewDatabaseFunction · 0.80
NewDatabaseFunction · 0.80
OpenFunction · 0.80
newPostgresDatabaseFunction · 0.80
newSQLiteDatabaseFunction · 0.80
NewDatabaseFunction · 0.80
NewDatabaseFunction · 0.80
NewDatabaseFunction · 0.80
NewDatabaseFunction · 0.80
NewDatabaseFunction · 0.80
NewDatabaseFunction · 0.80
NewDatabaseFunction · 0.80

Calls 1

OpenMethod · 0.65

Tested by

no test coverage detected