refactoring pool, replace zap.Duration with zap.Stringer

This commit is contained in:
Evgeniy Kulikov 2020-02-25 18:35:46 +03:00
parent cf61136da5
commit 62c6bbd875
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2
3 changed files with 47 additions and 16 deletions

16
main.go
View file

@ -23,6 +23,9 @@ type router struct {
func main() {
var (
err error
pool *Pool
v = settings()
l = newLogger(v)
g = newGracefulContext(l)
@ -32,10 +35,21 @@ func main() {
grpclog.SetLoggerV2(gRPCLogger(l))
}
switch pool, err = newPool(g, l, v); {
case err == nil:
// ignore
case errors.Is(err, context.Canceled):
l.Info("close application")
return
default:
l.Error("could get connection", zap.Error(err))
return
}
r := &router{
log: l,
pool: pool,
key: fetchKey(l, v),
pool: newPool(g, l, v),
timeout: v.GetDuration("request_timeout"),
}