Refactor the Periodic Scanner module (#1210)

* Initial fix of a race condition

* better logging

* some refactoring and graceful shutdown

* fix more potential race condition places; a better app shutdown

* add test and fix some issues

* some housekeeping

* more descriptive asserts

* Address review suggestions

* Better server shutdown logic + better message about the .env file not found

* Create context inside the shutdown goroutine; removed unnecessary shutdown from the main function

* Move HTTP server to the main process and remove unnecessary code

* log shutdown error if any

* Get back to the local `scanner` variable

* Protecting scanner with mutex

* Adding the mutex to the shutdown function

* Addressing the race condition at the init stage

---------

Co-authored-by: Konstantin Koval
This commit is contained in:
Kostiantyn
2025-06-11 17:09:22 +03:00
committed by GitHub
parent 0da8bef69e
commit a22967b7d0
5 changed files with 428 additions and 29 deletions

View File

@@ -53,6 +53,7 @@ require (
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sosodev/duration v1.3.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/urfave/cli/v2 v2.27.6 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
golang.org/x/mod v0.24.0 // indirect