Skip to content

Commit

Permalink
rearrange code based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrks committed Sep 20, 2024
1 parent 50ffa43 commit c7f944e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions rest/server_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,6 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config
dbName = spec.BucketName
}

// Generate database context options from config and server context
contextOptions, err := dbcOptionsFromConfig(ctx, sc, &config.DbConfig, dbName)
if err != nil {
return nil, err
}
// set this early so we have dbName available in db-init related logging, before we have an actual database
ctx = base.DatabaseLogCtx(ctx, dbName, contextOptions.LoggingConfig)

defer func() {
if returnedError == nil {
return
Expand All @@ -616,10 +608,6 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config
return nil, err
}

if spec.Server == "" {
spec.Server = sc.Config.Bootstrap.Server
}

previousDatabase := sc.databases_[dbName]
if previousDatabase != nil {
if options.useExisting {
Expand All @@ -630,6 +618,18 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config
"Duplicate database name %q", dbName)
}

// Generate database context options from config and server context
contextOptions, err := dbcOptionsFromConfig(ctx, sc, &config.DbConfig, dbName)
if err != nil {
return nil, err
}
// set this early so we have dbName available in db-init related logging, before we have an actual database
ctx = base.DatabaseLogCtx(ctx, dbName, contextOptions.LoggingConfig)

if spec.Server == "" {
spec.Server = sc.Config.Bootstrap.Server
}

// Connect to bucket
base.InfofCtx(ctx, base.KeyAll, "Opening db /%s as bucket %q, pool %q, server <%s>",
base.MD(dbName), base.MD(spec.BucketName), base.SD(base.DefaultPool), base.SD(spec.Server))
Expand Down

0 comments on commit c7f944e

Please sign in to comment.