From e2f697f94a184ae22382030cf9f2e6abc43851bf Mon Sep 17 00:00:00 2001 From: Alexey Kiselev Date: Thu, 12 Dec 2024 11:33:44 +0400 Subject: [PATCH] Move constant into function were it used. Proper error declaration. --- pkg/networking/network.go | 4 ++-- pkg/networking/timers.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/networking/network.go b/pkg/networking/network.go index 6715f24ed..df36a64fa 100644 --- a/pkg/networking/network.go +++ b/pkg/networking/network.go @@ -3,12 +3,12 @@ package networking import ( "context" "errors" - "fmt" "io" ) const Namespace = "NET" +// TODO: Consider special Error type for all [networking] errors. var ( // ErrInvalidConfigurationNoProtocol is used when the configuration has no protocol. ErrInvalidConfigurationNoProtocol = errors.New("invalid configuration: empty protocol") @@ -23,7 +23,7 @@ var ( ErrSessionShutdown = errors.New("session shutdown") // ErrConnectionWriteTimeout indicates that we hit the timeout writing to the underlying stream connection. - ErrConnectionWriteTimeout = fmt.Errorf("connection write timeout") + ErrConnectionWriteTimeout = errors.New("connection write timeout") // ErrKeepAliveProtocolFailure is used when the protocol failed to provide a keep-alive message. ErrKeepAliveProtocolFailure = errors.New("protocol failed to provide a keep-alive message") diff --git a/pkg/networking/timers.go b/pkg/networking/timers.go index 6492297a8..9dd227c8a 100644 --- a/pkg/networking/timers.go +++ b/pkg/networking/timers.go @@ -5,13 +5,12 @@ import ( "time" ) -const initialTimerInterval = time.Hour * 1e6 - type timerPool struct { p *sync.Pool } func newTimerPool() *timerPool { + const initialTimerInterval = time.Hour * 1e6 return &timerPool{ p: &sync.Pool{ New: func() any {