all: fix todo
This commit is contained in:
parent
3203300e7a
commit
f763b91017
|
@ -57,7 +57,6 @@ type configJSONv2 struct {
|
|||
|
||||
// Register web handlers
|
||||
func (l *queryLog) initWeb() {
|
||||
// TODO(s.chzhen): Remove deprecated API.
|
||||
l.conf.HTTPRegister(http.MethodGet, "/control/querylog", l.handleQueryLog)
|
||||
l.conf.HTTPRegister(http.MethodGet, "/control/querylog_info", l.handleQueryLogInfo)
|
||||
l.conf.HTTPRegister(http.MethodPost, "/control/querylog_clear", l.handleQueryLogClear)
|
||||
|
@ -98,6 +97,8 @@ func (l *queryLog) handleQueryLogClear(_ http.ResponseWriter, _ *http.Request) {
|
|||
|
||||
// handleQueryLogInfo handles requests to the GET /control/querylog_info
|
||||
// endpoint.
|
||||
//
|
||||
// Deprecated: Remove it when migration to the new API is over.
|
||||
func (l *queryLog) handleQueryLogInfo(w http.ResponseWriter, r *http.Request) {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
@ -116,8 +117,8 @@ func (l *queryLog) handleQueryLogInfo(w http.ResponseWriter, r *http.Request) {
|
|||
})
|
||||
}
|
||||
|
||||
// handleQueryLogInfoV2 handles requests to the GET
|
||||
// /control/querylog/config endpoint.
|
||||
// handleQueryLogInfoV2 handles requests to the GET /control/querylog/config
|
||||
// endpoint.
|
||||
func (l *queryLog) handleQueryLogInfoV2(w http.ResponseWriter, r *http.Request) {
|
||||
l.lock.Lock()
|
||||
defer l.lock.Unlock()
|
||||
|
@ -146,6 +147,8 @@ func AnonymizeIP(ip net.IP) {
|
|||
}
|
||||
|
||||
// handleQueryLogConfig handles the POST /control/querylog_config queries.
|
||||
//
|
||||
// Deprecated: Remove it when migration to the new API is over.
|
||||
func (l *queryLog) handleQueryLogConfig(w http.ResponseWriter, r *http.Request) {
|
||||
// Set NaN as initial value to be able to know if it changed later by
|
||||
// comparing it to NaN.
|
||||
|
|
|
@ -80,6 +80,8 @@ type configRespV2 struct {
|
|||
}
|
||||
|
||||
// handleStatsInfo handles requests to the GET /control/stats_info endpoint.
|
||||
//
|
||||
// Deprecated: Remove it when migration to the new API is over.
|
||||
func (s *StatsCtx) handleStatsInfo(w http.ResponseWriter, r *http.Request) {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
@ -117,6 +119,8 @@ func (s *StatsCtx) handleStatsInfoV2(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// handleStatsConfig handles requests to the POST /control/stats_config
|
||||
// endpoint.
|
||||
//
|
||||
// Deprecated: Remove it when migration to the new API is over.
|
||||
func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
|
||||
reqData := configResp{}
|
||||
err := json.NewDecoder(r.Body).Decode(&reqData)
|
||||
|
@ -137,10 +141,10 @@ func (s *StatsCtx) handleStatsConfig(w http.ResponseWriter, r *http.Request) {
|
|||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
s.setLimit(int(reqData.IntervalDays))
|
||||
s.setLimitLocked(int(reqData.IntervalDays))
|
||||
}
|
||||
|
||||
// handleStatsConfigV2 handles requests to the POST /control/stats_config
|
||||
// handleStatsConfigV2 handles requests to the PUT /control/stats_config
|
||||
// endpoint.
|
||||
func (s *StatsCtx) handleStatsConfigV2(w http.ResponseWriter, r *http.Request) {
|
||||
reqData := configRespV2{}
|
||||
|
@ -194,7 +198,6 @@ func (s *StatsCtx) initWeb() {
|
|||
return
|
||||
}
|
||||
|
||||
// TODO(s.chzhen): Remove deprecated API.
|
||||
s.httpRegister(http.MethodGet, "/control/stats", s.handleStats)
|
||||
s.httpRegister(http.MethodPost, "/control/stats_reset", s.handleStatsReset)
|
||||
s.httpRegister(http.MethodPost, "/control/stats_config", s.handleStatsConfig)
|
||||
|
|
|
@ -131,9 +131,11 @@ func New(conf Config) (s *StatsCtx, err error) {
|
|||
if conf.LimitIvl < time.Hour {
|
||||
return nil, errors.Error("interval: less than an hour")
|
||||
}
|
||||
|
||||
if conf.LimitIvl > timeutil.Day*365 {
|
||||
return nil, errors.Error("interval: more than a year")
|
||||
}
|
||||
|
||||
s.limitIvl = conf.LimitIvl
|
||||
|
||||
if s.unitIDGen = newUnitID; conf.UnitID != nil {
|
||||
|
@ -268,7 +270,7 @@ func (s *StatsCtx) WriteDiskConfig(dc *Config) {
|
|||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
dc.LimitIvl = s.limitIvl / 24
|
||||
dc.LimitIvl = s.limitIvl
|
||||
dc.Enabled = s.enabled
|
||||
dc.Ignored = s.ignored
|
||||
}
|
||||
|
@ -442,7 +444,9 @@ func (s *StatsCtx) periodicFlush() {
|
|||
}
|
||||
|
||||
// s.lock is expected to be locked.
|
||||
func (s *StatsCtx) setLimit(limitDays int) {
|
||||
//
|
||||
// TODO(s.chzhen): Remove it when migration to the new API is over.
|
||||
func (s *StatsCtx) setLimitLocked(limitDays int) {
|
||||
if limitDays != 0 {
|
||||
s.enabled = true
|
||||
s.limitIvl = time.Duration(int(timeutil.Day) * limitDays)
|
||||
|
|
Loading…
Reference in New Issue