45 lines
614 B
Go
45 lines
614 B
Go
package mongox
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"mongo.games.com/goserver/core"
|
|
"mongo.games.com/goserver/core/viperx"
|
|
)
|
|
|
|
var config = Configuration{}
|
|
|
|
type Configuration struct {
|
|
Path string
|
|
}
|
|
|
|
func (c *Configuration) Name() string {
|
|
return "mongox"
|
|
}
|
|
|
|
func (c *Configuration) Init() error {
|
|
if c.Path == "" {
|
|
c.Path = "mongo.yaml"
|
|
}
|
|
|
|
vp := viperx.GetViper(c.Path)
|
|
|
|
cfg := &Config{}
|
|
if err := vp.Unmarshal(cfg); err != nil {
|
|
panic(fmt.Sprintf("mongox init error: %v", err))
|
|
}
|
|
|
|
Init(cfg)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c *Configuration) Close() error {
|
|
Close()
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
core.RegistePackage(&config)
|
|
}
|