MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / GetActiveDatabase

Method GetActiveDatabase

rest/server_context.go:330–340  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
330func (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.

Calls 4

ValidateDatabaseNameFunction · 0.92
HTTPErrorfFunction · 0.92
RLockMethod · 0.80
RUnlockMethod · 0.80