(base *graphjinEngine, nextConf *Config, reloadSet map[string]struct{}, opts ...Option)
| 1065 | } |
| 1066 | |
| 1067 | func (g *GraphJin) newGraphJinReloadingConfigDatabases(base *graphjinEngine, nextConf *Config, reloadSet map[string]struct{}, opts ...Option) error { |
| 1068 | if base == nil { |
| 1069 | return errors.New("graphjin engine is not initialized") |
| 1070 | } |
| 1071 | conf := nextConf.clone() |
| 1072 | if conf.IsSourcesUsed() { |
| 1073 | for i := range conf.Tables { |
| 1074 | if conf.Tables[i].Source == "" && conf.Tables[i].Database != "" { |
| 1075 | conf.Tables[i].Source = conf.Tables[i].Database |
| 1076 | } |
| 1077 | } |
| 1078 | } |
| 1079 | if err := conf.NormalizeMode(); err != nil { |
| 1080 | return err |
| 1081 | } |
| 1082 | |
| 1083 | log := base.log |
| 1084 | if log == nil { |
| 1085 | log = _log.New(os.Stderr, "", 0) |
| 1086 | } |
| 1087 | trace := base.trace |
| 1088 | if trace == nil { |
| 1089 | trace = &tracer{} |
| 1090 | } |
| 1091 | printFormat := append([]byte(nil), base.printFormat...) |
| 1092 | if len(printFormat) == 0 { |
| 1093 | printFormat = []byte(fmt.Sprintf("gj-%x:", time.Now().UnixNano())) |
| 1094 | } |
| 1095 | |
| 1096 | gj := &graphjinEngine{ |
| 1097 | conf: conf, |
| 1098 | log: log, |
| 1099 | prod: conf.Production, |
| 1100 | prodSec: conf.Production, |
| 1101 | printFormat: printFormat, |
| 1102 | opts: opts, |
| 1103 | fs: base.fs, |
| 1104 | trace: trace, |
| 1105 | namespace: base.namespace, |
| 1106 | done: g.done, |
| 1107 | } |
| 1108 | if gj.conf.DisableProdSecurity { |
| 1109 | gj.prodSec = false |
| 1110 | } |
| 1111 | if err := gj.initCache(); err != nil { |
| 1112 | return err |
| 1113 | } |
| 1114 | if err := gj.initConfig(); err != nil { |
| 1115 | return err |
| 1116 | } |
| 1117 | names := make([]string, 0, len(gj.conf.Databases)) |
| 1118 | for name := range gj.conf.Databases { |
| 1119 | names = append(names, name) |
| 1120 | } |
| 1121 | sort.Strings(names) |
| 1122 | if len(names) != 0 { |
| 1123 | gj.defaultDB = names[0] |
| 1124 | } |
no test coverage detected