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

Method getOrAddDatabaseFromConfig

rest/server_context.go:593–598  ·  view source on GitHub ↗

Adds a database to the ServerContext. Attempts a read after it gets the write lock to see if it's already been added by another process. If so, returns either the existing DatabaseContext or an error based on the useExisting flag.

(ctx context.Context, config DatabaseConfig, options getOrAddDatabaseConfigOptions)

Source from the content-addressed store, hash-verified

591// lock to see if it's already been added by another process. If so, returns either the
592// existing DatabaseContext or an error based on the useExisting flag.
593func (sc *ServerContext) getOrAddDatabaseFromConfig(ctx context.Context, config DatabaseConfig, options getOrAddDatabaseConfigOptions) (*db.DatabaseContext, error) {
594 // Obtain write lock during add database, to avoid race condition when creating based on ConfigServer
595 sc._databasesLock.Lock()
596 defer sc._databasesLock.Unlock()
597 return sc._getOrAddDatabaseFromConfig(ctx, config, options)
598}
599
600// GetBucketSpec returns a BucketSpec from a given DatabaseConfig and StartupConfig.
601func GetBucketSpec(ctx context.Context, config *DatabaseConfig, serverConfig *StartupConfig) (base.BucketSpec, error) {

Calls 3

LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected