Move stats to a separate package

chubin/logging
Igor Chubin 2 years ago
parent aef41c375e
commit 0d42c23d5b

@ -14,6 +14,7 @@ import (
"github.com/chubin/wttr.in/internal/config"
"github.com/chubin/wttr.in/internal/routing"
"github.com/chubin/wttr.in/internal/stats"
lru "github.com/hashicorp/golang-lru"
)
@ -32,7 +33,7 @@ type RequestProcessor struct {
peakRequest30 sync.Map
peakRequest60 sync.Map
lruCache *lru.Cache
stats *Stats
stats *stats.Stats
router routing.Router
upstreamTransport *http.Transport
config *config.Config
@ -59,7 +60,7 @@ func NewRequestProcessor(config *config.Config) (*RequestProcessor, error) {
rp := &RequestProcessor{
lruCache: lruCache,
stats: NewStats(),
stats: stats.New(),
upstreamTransport: transport,
config: config,
}

@ -1,4 +1,4 @@
package main
package stats
import (
"bytes"
@ -17,8 +17,8 @@ type Stats struct {
startTime time.Time
}
// NewStats returns new Stats.
func NewStats() *Stats {
// New returns new Stats.
func New() *Stats {
return &Stats{
v: map[string]int{},
startTime: time.Now(),
Loading…
Cancel
Save