signoz/pkg/sqlmigrator/config.go
Vibhu Pandey dc15ee8176
feat(sqlmigration): consolidate all sqlmigrations into one package (#7018)
* feat(sqlmigration): add sqlmigrations

* feat(sqlmigration): test sqlmigrations

* feat(sqlmigration): add remaining factories

* feat(sqlmigration): consolidate into single package

* fix(telemetrystore): remove existing env variables

* fix(telemetrystore): fix DSN
2025-02-04 09:23:36 +00:00

42 lines
856 B
Go

package sqlmigrator
import (
"errors"
"time"
"go.signoz.io/signoz/pkg/factory"
)
type Config struct {
// Lock is the lock configuration.
Lock Lock `mapstructure:"lock"`
}
type Lock struct {
// Timeout is the time to wait for the migration lock.
Timeout time.Duration `mapstructure:"timeout"`
// Interval is the interval to try to acquire the migration lock.
Interval time.Duration `mapstructure:"interval"`
}
func NewConfigFactory() factory.ConfigFactory {
return factory.NewConfigFactory(factory.MustNewName("sqlmigrator"), newConfig)
}
func newConfig() factory.Config {
return Config{
Lock: Lock{
Timeout: 2 * time.Minute,
Interval: 10 * time.Second,
},
}
}
func (c Config) Validate() error {
if c.Lock.Timeout <= c.Lock.Interval {
return errors.New("lock::timeout must be greater than lock::interval")
}
return nil
}