Remove sdk context dep

Signed-off-by: Pavel Korotkov <pavel@nspcc.ru>
This commit is contained in:
Pavel Korotkov 2021-03-25 11:27:59 +03:00 committed by Pavel Korotkov
parent f77c4e49dc
commit cdab794d62
2 changed files with 23 additions and 8 deletions

20
global/context.go Normal file
View file

@ -0,0 +1,20 @@
package global
import (
"context"
"os/signal"
"sync"
"syscall"
)
var (
globalContext context.Context
globalContexOnce sync.Once
)
func Context() context.Context {
globalContexOnce.Do(func() {
globalContext, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
})
return globalContext
}