Read the drop counter atomically and set the WHOIS fetcher before serving (closes #115)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The read loop added to a handler's drop count atomically while the statistics endpoint and the metrics log read it as a plain field, a data race whenever messages were dropped. The count is now an atomic.Uint64, read with Load. A test reads the handler statistics while the read loop drops messages for a handler that never finishes one. Run created the WHOIS fetcher and gave it to the HTTP server after the server had started, while request handlers could read it. The fetcher is now set before the server starts. Model: opus-5-5
This commit was merged in pull request #139.
This commit is contained in:
@@ -116,17 +116,18 @@ func (rw *RouteWatch) Run(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Start ASN WHOIS fetcher for background updates. The HTTP handlers read
|
||||
// the server's fetcher without a lock, so it is set before they run.
|
||||
rw.asnFetcher = NewASNFetcher(rw.db, rw.logger.Logger)
|
||||
rw.asnFetcher.Start(ctx)
|
||||
rw.server.SetASNFetcher(rw.asnFetcher)
|
||||
|
||||
// Start HTTP server
|
||||
err = rw.server.Start(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Start ASN WHOIS fetcher for background updates
|
||||
rw.asnFetcher = NewASNFetcher(rw.db, rw.logger.Logger)
|
||||
rw.asnFetcher.Start(ctx)
|
||||
rw.server.SetASNFetcher(rw.asnFetcher)
|
||||
|
||||
// Start database maintenance goroutine
|
||||
rw.dbMaintainer = NewDBMaintainer(rw.db, rw.logger.Logger)
|
||||
rw.dbMaintainer.Start(ctx)
|
||||
|
||||
Reference in New Issue
Block a user