aicra/loader.go

43 lines
880 B
Go
Raw Normal View History

package gfw
import (
2018-05-30 07:04:00 +00:00
"git.xdrm.io/xdrm-brackets/gfw/checker"
2018-05-30 07:06:26 +00:00
"git.xdrm.io/xdrm-brackets/gfw/config"
2018-06-01 07:09:26 +00:00
"git.xdrm.io/xdrm-brackets/gfw/err"
)
// Init initilises a new framework instance
//
// - path is the configuration path
//
// - if typeChecker is nil, defaults will be used (all *.so files
// inside ./types local directory)
//
func Init(path string, typeChecker *checker.TypeRegistry) (*Server, error) {
/* (1) Init instance */
inst := &Server{
config: nil,
Params: make(map[string]interface{}),
2018-06-01 07:09:26 +00:00
err: err.Success,
}
/* (2) Load configuration */
config, err := config.Load(path)
if err != nil {
return nil, err
}
inst.config = config
/* (3) Store registry if not nil */
if typeChecker != nil {
inst.Checker = typeChecker
return inst, nil
}
/* (4) Default registry creation */
inst.Checker = checker.CreateRegistry(true)
return inst, nil
}