aicra/loader.go

42 lines
842 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"
)
// 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{}),
err: ErrSuccess,
}
/* (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
}