Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
18
pkg/health/goroutines.go
Normal file
18
pkg/health/goroutines.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"context"
|
||||
"runtime"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func NewGoRoutinesCheck(threshold int) CheckFunc {
|
||||
return func(ctx context.Context) error {
|
||||
count := runtime.NumGoroutine()
|
||||
if count > threshold {
|
||||
return errors.Errorf("too many goroutines (%d > %d)", count, threshold)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user