[#19] Add a version with no cdn-sdk deps

Signed-off-by: Pavel Korotkov <pavel@nspcc.ru>
This commit is contained in:
Pavel Korotkov 2021-03-31 01:46:33 +03:00 committed by Pavel Korotkov
parent cdab794d62
commit 4c96885a42
20 changed files with 930 additions and 266 deletions

View file

@ -8,13 +8,16 @@ import (
)
var (
globalContext context.Context
globalContexOnce sync.Once
globalContext context.Context
globalContextOnce sync.Once
globalContextBarrier = make(chan struct{})
)
func Context() context.Context {
globalContexOnce.Do(func() {
globalContextOnce.Do(func() {
globalContext, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
close(globalContextBarrier)
})
<-globalContextBarrier
return globalContext
}