(opts ...LoaderConfOption)
| 67 | } |
| 68 | |
| 69 | func Load(opts ...LoaderConfOption) error { |
| 70 | conf := NewLoaderConf(opts...) |
| 71 | if conf.opts == nil { |
| 72 | koan := GetConfigResolver(conf) |
| 73 | koan = conf.MergeConfig(koan) |
| 74 | if err := koan.UnmarshalWithConf(instanceOptions.Prefix(), |
| 75 | instanceOptions, koanf.UnmarshalConf{Tag: "yaml"}); err != nil { |
| 76 | return err |
| 77 | } |
| 78 | } else { |
| 79 | instanceOptions = conf.opts |
| 80 | } |
| 81 | |
| 82 | if err := instanceOptions.init(); err != nil { |
| 83 | return err |
| 84 | } |
| 85 | |
| 86 | instance := &Instance{insOpts: instanceOptions} |
| 87 | // start the file watcher |
| 88 | once.Do(func() { |
| 89 | watcher.watcherWg.Add(1) |
| 90 | gr.GoSafely(&watcher.watcherWg, false, func() { |
| 91 | watch(conf, watcher.stopCh) |
| 92 | }, nil) |
| 93 | extension.AddCustomShutdownCallback(func() { |
| 94 | StopFileWatcher() |
| 95 | }) |
| 96 | }) |
| 97 | return instance.start() |
| 98 | } |
| 99 | |
| 100 | func watch(conf *loaderConf, stopCh <-chan struct{}) { |
| 101 | watcher, err := fsnotify.NewWatcher() |
nothing calls this directly
no test coverage detected