mirror of
https://github.com/chubin/wttr.in
synced 2024-11-14 16:17:19 +00:00
Move stats to a separate package
This commit is contained in:
parent
aef41c375e
commit
0d42c23d5b
2 changed files with 6 additions and 5 deletions
|
@ -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…
Reference in a new issue