GetActiveDatabase attempts to return the DatabaseContext of a loaded database. If not found, the database name will be validated to make sure it's valid and then an error returned.
(name string)
| 328 | // GetActiveDatabase attempts to return the DatabaseContext of a loaded database. If not found, the database name will be |
| 329 | // validated to make sure it's valid and then an error returned. |
| 330 | func (sc *ServerContext) GetActiveDatabase(name string) (*db.DatabaseContext, error) { |
| 331 | sc._databasesLock.RLock() |
| 332 | dbc := sc._databases[name] |
| 333 | sc._databasesLock.RUnlock() |
| 334 | if dbc != nil { |
| 335 | return dbc, nil |
| 336 | } else if db.ValidateDatabaseName(name) != nil { |
| 337 | return nil, base.HTTPErrorf(http.StatusBadRequest, "invalid database name %q", name) |
| 338 | } |
| 339 | return nil, base.ErrNotFound |
| 340 | } |
| 341 | |
| 342 | // GetInactiveDatabase attempts to load the database and return it's DatabaseContext. It will first attempt to unsuspend the |
| 343 | // database, and if that fails, try to load the database from the buckets. |