mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-27 10:47:06 +02:00
chore: cont. d8eff90
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/yusing/go-proxy/internal/common"
|
||||||
"github.com/yusing/go-proxy/internal/gperr"
|
"github.com/yusing/go-proxy/internal/gperr"
|
||||||
"github.com/yusing/go-proxy/internal/logging"
|
"github.com/yusing/go-proxy/internal/logging"
|
||||||
"github.com/yusing/go-proxy/internal/task"
|
"github.com/yusing/go-proxy/internal/task"
|
||||||
@@ -39,14 +40,12 @@ const (
|
|||||||
pollInterval = 1 * time.Second
|
pollInterval = 1 * time.Second
|
||||||
gatherErrsInterval = 30 * time.Second
|
gatherErrsInterval = 30 * time.Second
|
||||||
saveInterval = 5 * time.Minute
|
saveInterval = 5 * time.Minute
|
||||||
|
|
||||||
saveBaseDir = "data/metrics"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var initDataDirOnce sync.Once
|
var initDataDirOnce sync.Once
|
||||||
|
|
||||||
func initDataDir() {
|
func initDataDir() {
|
||||||
if err := os.MkdirAll(saveBaseDir, 0o755); err != nil {
|
if err := os.MkdirAll(common.MetricsDataDir, 0o755); err != nil {
|
||||||
logging.Error().Err(err).Msg("failed to create metrics data directory")
|
logging.Error().Err(err).Msg("failed to create metrics data directory")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +64,7 @@ func NewPoller[T any, AggregateT json.Marshaler](
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Poller[T, AggregateT]) savePath() string {
|
func (p *Poller[T, AggregateT]) savePath() string {
|
||||||
return filepath.Join(saveBaseDir, fmt.Sprintf("%s.json", p.name))
|
return filepath.Join(common.MetricsDataDir, fmt.Sprintf("%s.json", p.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Poller[T, AggregateT]) load() error {
|
func (p *Poller[T, AggregateT]) load() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user