added manger to keep track of go routines in the services (#2869)

- added manager to wait for all go routines to end before exit
- code refactor
- renamed Manafer to Interface and GoRoutineManager to GroupManager
- replaced some go routine calls with manager Add func
- added unit tests for manager
This commit is contained in:
Vardhaman Surana
2023-11-07 15:30:48 +05:30
committed by GitHub
parent 27132975c4
commit 2a40b4538c
24 changed files with 283 additions and 67 deletions
+8 -1
View File
@@ -18,6 +18,7 @@ import (
config "github.com/fission/fission/pkg/featureconfig"
"github.com/fission/fission/pkg/utils/httpserver"
"github.com/fission/fission/pkg/utils/loggerfactory"
"github.com/fission/fission/pkg/utils/manager"
"github.com/fission/fission/pkg/utils/metrics"
)
@@ -59,6 +60,10 @@ func GetRouterWithAuth() *mux.Router {
}
func TestRouterAuth(t *testing.T) {
mgr := manager.New()
defer mgr.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
teardown := setup(t)
@@ -66,7 +71,9 @@ func TestRouterAuth(t *testing.T) {
logger := loggerfactory.GetLogger()
testmux := GetRouterWithAuth()
go httpserver.StartServer(ctx, logger, "test", "8990", testmux)
mgr.Add(ctx, func(ctx context.Context) {
httpserver.StartServer(ctx, logger, mgr, "test", "8990", testmux)
})
postBody, _ := json.Marshal(map[string]string{
"username": "Foo",