Files
zeekayandHanzo Dev c6c6cc6219 Go 1.27.1, and the code it can say more simply
The module declares go 1.27.1 and CI follows. go fix applied the
modernizers; omitzero is not applied, since it changes what the JSON
says.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-16 19:52:34 -07:00

49 lines
1.0 KiB
Go

// Copyright (C) 2020-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package factory
import (
"github.com/luxfi/database"
"github.com/luxfi/log"
"github.com/luxfi/metric"
)
// DatabaseConfig is a convenience struct for database configuration
type DatabaseConfig struct {
Type string
Dir string
Name string
ReadOnly bool
Config []byte
MetricsReg metric.Registerer
Logger log.Logger
MetricsPrefix string
MeterDBRegName string
}
// NewFromConfig creates a new database from a DatabaseConfig
func NewFromConfig(cfg DatabaseConfig) (database.Database, error) {
// Default logger if not provided
if cfg.Logger.IsZero() {
cfg.Logger = log.Noop()
}
// Convert Registerer to interface{} for the factory
var gatherer any
if cfg.MetricsReg != nil {
gatherer = cfg.MetricsReg
}
return New(
cfg.Type,
cfg.Dir,
cfg.ReadOnly,
cfg.Config,
gatherer,
cfg.Logger,
cfg.MetricsPrefix,
cfg.MeterDBRegName,
)
}