Run initiates the control loop in the background, which spawns a given number of notifier goroutines. Manager requires system-level permissions to interact with the store. Run is only intended to be run once.
(ctx context.Context)
| 141 | // Manager requires system-level permissions to interact with the store. |
| 142 | // Run is only intended to be run once. |
| 143 | func (m *Manager) Run(ctx context.Context) { |
| 144 | m.log.Debug(ctx, "notification manager started") |
| 145 | |
| 146 | m.runOnce.Do(func() { |
| 147 | // Closes when Stop() is called or context is canceled. |
| 148 | pproflabel.Go(ctx, pproflabel.Service(pproflabel.ServiceNotifications), func(ctx context.Context) { |
| 149 | err := m.loop(ctx) |
| 150 | if err != nil { |
| 151 | if xerrors.Is(err, ErrManagerAlreadyClosed) { |
| 152 | m.log.Warn(ctx, "notification manager stopped with error", slog.Error(err)) |
| 153 | } else { |
| 154 | m.log.Error(ctx, "notification manager stopped with error", slog.Error(err)) |
| 155 | } |
| 156 | } |
| 157 | }) |
| 158 | }) |
| 159 | } |
| 160 | |
| 161 | // loop contains the main business logic of the notification manager. It is responsible for subscribing to notification |
| 162 | // events, creating a notifier, and publishing bulk dispatch result updates to the store. |