(base *graphjinEngine, database string)
| 1223 | } |
| 1224 | |
| 1225 | func (g *GraphJin) newGraphJinReloadingDatabase(base *graphjinEngine, database string) error { |
| 1226 | if base == nil { |
| 1227 | return errors.New("graphjin engine is not initialized") |
| 1228 | } |
| 1229 | conf := base.conf.clone() |
| 1230 | if conf.IsSourcesUsed() { |
| 1231 | for i := range conf.Tables { |
| 1232 | if conf.Tables[i].Source == "" && conf.Tables[i].Database != "" { |
| 1233 | conf.Tables[i].Source = conf.Tables[i].Database |
| 1234 | } |
| 1235 | } |
| 1236 | } |
| 1237 | if err := conf.NormalizeMode(); err != nil { |
| 1238 | return err |
| 1239 | } |
| 1240 | |
| 1241 | log := base.log |
| 1242 | if log == nil { |
| 1243 | log = _log.New(os.Stderr, "", 0) |
| 1244 | } |
| 1245 | trace := base.trace |
| 1246 | if trace == nil { |
| 1247 | trace = &tracer{} |
| 1248 | } |
| 1249 | printFormat := append([]byte(nil), base.printFormat...) |
| 1250 | if len(printFormat) == 0 { |
| 1251 | printFormat = []byte(fmt.Sprintf("gj-%x:", time.Now().UnixNano())) |
| 1252 | } |
| 1253 | |
| 1254 | gj := &graphjinEngine{ |
| 1255 | conf: conf, |
| 1256 | log: log, |
| 1257 | prod: conf.Production, |
| 1258 | prodSec: conf.Production, |
| 1259 | printFormat: printFormat, |
| 1260 | opts: base.opts, |
| 1261 | fs: base.fs, |
| 1262 | trace: trace, |
| 1263 | namespace: base.namespace, |
| 1264 | done: g.done, |
| 1265 | } |
| 1266 | if gj.conf.DisableProdSecurity { |
| 1267 | gj.prodSec = false |
| 1268 | } |
| 1269 | if err := gj.initCache(); err != nil { |
| 1270 | return err |
| 1271 | } |
| 1272 | if err := gj.initConfig(); err != nil { |
| 1273 | return err |
| 1274 | } |
| 1275 | gj.defaultDB = base.defaultDB |
| 1276 | if gj.defaultDB == "" { |
| 1277 | names := make([]string, 0, len(gj.conf.Databases)) |
| 1278 | for name := range gj.conf.Databases { |
| 1279 | names = append(names, name) |
| 1280 | } |
| 1281 | sort.Strings(names) |
| 1282 | if len(names) != 0 { |
no test coverage detected