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)
| 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. |
| 593 | func (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. |
| 601 | func GetBucketSpec(ctx context.Context, config *DatabaseConfig, serverConfig *StartupConfig) (base.BucketSpec, error) { |
no test coverage detected