package config

import (
	"eta/eta_mini_ht_api/common/contants"
	"sync"
)

var (
	glOnce   sync.Once
	glConfig *GLConfig
)

type GLOpts struct {
	DBUrl string
}
type GLConfig struct {
	BaseConfig
	opts GLOpts
}

func (r *GLConfig) GetDBUrl() string {
	return r.opts.DBUrl
}

func (r *GLConfig) InitConfig() {
	opts := GLOpts{
		DBUrl: r.GetString("database.url"),
	}
	r.opts = opts
}
func NewGLConfig() Config {
	if glConfig == nil {
		glOnce.Do(func() {
			glConfig = &GLConfig{
				BaseConfig: BaseConfig{prefix: contants.GL},
				opts:       GLOpts{},
			}
		})
	}
	return glConfig
}

func init() {
	Register(contants.GL, NewGLConfig)
}
