Source File
cmdconfig.go
Belonging Package
golang.org/x/pkgsite/cmd/internal/cmdconfig
package cmdconfig
import (
_ // for pgx driver
)
func ( context.Context, *config.Config, string) middleware.Logger {
if .OnGCP() {
, := log.UseStackdriver(, , )
if != nil {
log.Fatal(, )
}
return
}
return middleware.LocalLogger{}
}
func ( context.Context, *config.Config) *errorreporting.Client {
if !.OnGCP() || .DisableErrorReporting {
return nil
}
, := errorreporting.NewClient(, .ProjectID, errorreporting.Config{
ServiceName: .ServiceID,
OnError: func( error) {
log.Errorf(, "Error reporting failed: %v", )
},
})
if != nil {
log.Fatal(, )
}
derrors.SetReportingClient()
return
}
func ( context.Context, *config.Config, middleware.ExperimentGetter, *errorreporting.Client) *middleware.Experimenter {
, := middleware.NewExperimenter(, 1*time.Minute, , )
if != nil {
log.Fatal(, )
}
return
}
func ( context.Context, *config.Config) middleware.ExperimentGetter {
if .DynamicConfigLocation == "" {
log.Warningf(, "experiments are not configured")
return func(context.Context) ([]*internal.Experiment, error) { return nil, nil }
}
log.Infof(, "using dynamic config from %s for experiments", .DynamicConfigLocation)
return func( context.Context) ([]*internal.Experiment, error) {
, := dynconfig.Read(, .DynamicConfigLocation)
if != nil {
return nil,
}
var []string
for , := range .Experiments {
= append(, fmt.Sprintf("%s:%d", .Name, .Rollout))
if , := internal.Experiments[.Name]; {
if .Description == "" {
.Description =
}
} else {
log.Errorf(, "unknown experiment %q", .Name)
}
}
log.Infof(, "read experiments %s", strings.Join(, ", "))
return .Experiments, nil
}
}
, := database.RegisterOCWrapper(.DBDriver, ocsql.WithAllTraceOptions())
if != nil {
return nil, fmt.Errorf("unable to register the ocsql driver: %v", )
}
log.Infof(, "opening database on host %s", .DBHost)
, := database.Open(, .DBConnInfo(), .InstanceID)
if == nil {
log.Infof(, "connected to primary host: %s", .DBHost)
} else {
:= .DBSecondaryConnInfo()
if == "" {
log.Infof(, "no secondary DB host")
return nil,
}
log.Errorf(, "database.Open for primary host %s failed with %v; trying secondary host %s ",
.DBHost, , .DBSecondaryHost)
, = database.Open(, , .InstanceID)
if != nil {
return nil,
}
log.Infof(, "connected to secondary host %s", .DBSecondaryHost)
}
log.Infof(, "database open finished")
if {
return postgres.NewBypassingLicenseCheck(), nil
}
return postgres.New(), nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |