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
@@ -12,9 +12,13 @@ import (
"go.uber.org/zap"
"github.com/fission/fission/pkg/utils/loggerfactory"
"github.com/fission/fission/pkg/utils/manager"
)
func TestStartServer(t *testing.T) {
mgr := manager.New()
defer mgr.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
logger := loggerfactory.GetLogger()
@@ -26,7 +30,10 @@ func TestStartServer(t *testing.T) {
logger.Error("failed to write response", zap.Error(err))
}
}))
go StartServer(ctx, logger, "test", "8999", m)
mgr.Add(ctx, func(ctx context.Context) {
StartServer(ctx, logger, mgr, "test", "8999", m)
})
tests := []struct {
Name string