(ctx context.Context)
| 27 | var databaseWatcher common.Watcher |
| 28 | |
| 29 | func InitWatcher(ctx context.Context) { |
| 30 | if databaseWatcher != nil { |
| 31 | return |
| 32 | } |
| 33 | ctx = garmUtil.WithSlogContext(ctx, slog.Any("watcher", "database")) |
| 34 | w := &watcher{ |
| 35 | producers: make(map[string]*producer), |
| 36 | consumers: make(map[string]*consumer), |
| 37 | quit: make(chan struct{}), |
| 38 | ctx: ctx, |
| 39 | } |
| 40 | |
| 41 | go w.loop() |
| 42 | databaseWatcher = w |
| 43 | } |
| 44 | |
| 45 | func CloseWatcher() error { |
| 46 | if databaseWatcher == nil { |