New returns a new job reaper.
(ctx context.Context, db database.Store, pub pubsub.Pubsub, log slog.Logger, tick <-chan time.Time)
| 111 | |
| 112 | // New returns a new job reaper. |
| 113 | func New(ctx context.Context, db database.Store, pub pubsub.Pubsub, log slog.Logger, tick <-chan time.Time) *Detector { |
| 114 | //nolint:gocritic // Job reaper has a limited set of permissions. |
| 115 | ctx, cancel := context.WithCancel(dbauthz.AsJobReaper(ctx)) |
| 116 | d := &Detector{ |
| 117 | ctx: ctx, |
| 118 | cancel: cancel, |
| 119 | done: make(chan struct{}), |
| 120 | db: db, |
| 121 | pubsub: pub, |
| 122 | log: log, |
| 123 | tick: tick, |
| 124 | stats: nil, |
| 125 | } |
| 126 | return d |
| 127 | } |
| 128 | |
| 129 | // WithStatsChannel will cause Executor to push a RunStats to ch after |
| 130 | // every tick. This push is blocking, so if ch is not read, the detector will |