NewService constructs a chat debug persistence service.
(db database.Store, log slog.Logger, ps pubsub.Pubsub, opts ...ServiceOption)
| 143 | |
| 144 | // NewService constructs a chat debug persistence service. |
| 145 | func NewService(db database.Store, log slog.Logger, ps pubsub.Pubsub, opts ...ServiceOption) *Service { |
| 146 | if db == nil { |
| 147 | panic("chatdebug: nil database.Store") |
| 148 | } |
| 149 | |
| 150 | s := &Service{ |
| 151 | db: db, |
| 152 | log: log, |
| 153 | pubsub: ps, |
| 154 | clock: quartz.NewReal(), |
| 155 | thresholdChanged: make(chan struct{}), |
| 156 | } |
| 157 | s.staleAfterNanos.Store(DefaultStaleThreshold.Nanoseconds()) |
| 158 | for _, opt := range opts { |
| 159 | opt(s) |
| 160 | } |
| 161 | return s |
| 162 | } |
| 163 | |
| 164 | // SetStaleAfter overrides the in-flight stale threshold used when |
| 165 | // finalizing abandoned debug rows. Zero or negative durations are |