Add connection pool implementation (part 2)

Signed-off-by: Pavel Korotkov <pavel@nspcc.ru>
This commit is contained in:
Pavel Korotkov 2021-04-05 20:10:03 +03:00 committed by Pavel Korotkov
parent 62a03251ce
commit a44551d42b
6 changed files with 70 additions and 57 deletions

View file

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