drop 'global' package

It makes no sense as a package.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2021-05-25 13:23:29 +03:00
parent 6c73296012
commit 8ba5a2c92a
2 changed files with 5 additions and 24 deletions

View file

@ -1,22 +0,0 @@
package global
import (
"context"
"os/signal"
"sync"
"syscall"
)
var (
globalContext context.Context
globalContextOnce sync.Once
)
// Context returns global context with initialized INT, TERM and HUP signal
// handlers set to notify this context.
func Context() context.Context {
globalContextOnce.Do(func() {
globalContext, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
})
return globalContext
}

View file

@ -1,7 +1,10 @@
package main package main
import ( import (
"github.com/nspcc-dev/neofs-http-gw/global" "context"
"os/signal"
"syscall"
"github.com/nspcc-dev/neofs-http-gw/logger" "github.com/nspcc-dev/neofs-http-gw/logger"
"github.com/spf13/viper" "github.com/spf13/viper"
"go.uber.org/zap" "go.uber.org/zap"
@ -12,7 +15,7 @@ func main() {
v = settings() v = settings()
l = newLogger(v) l = newLogger(v)
) )
globalContext := global.Context() globalContext, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
app := newApp(globalContext, WithLogger(l), WithConfig(v)) app := newApp(globalContext, WithLogger(l), WithConfig(v))
go app.Serve(globalContext) go app.Serve(globalContext)
app.Wait() app.Wait()