zhangzengfei
2024-04-16 ca9e545d6fcc86e751e768f57d823704e9ad1340
修复更新重试次数
4个文件已修改
11 ■■■■ 已修改文件
config/config.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cron/cron.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/cache.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/resend.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/config.go
@@ -27,6 +27,7 @@
    SyncServer     string `mapstructure:"sync-server"`
    ReportServer   string `mapstructure:"report-server"`
    ReportInterval int    `mapstructure:"report-interval"`
    RetryInterval  int    `mapstructure:"retry-interval"`
}
type rateLimitConfig struct {
@@ -73,5 +74,9 @@
        ForwardConf.ReportInterval = 10
    }
    if ForwardConf.RetryInterval == 0 {
        ForwardConf.RetryInterval = 5
    }
    logger.SetLogLevel(LogConf.Level)
}
cron/cron.go
@@ -14,7 +14,7 @@
}
func Init() {
    s.Every(10).Minutes().StartImmediately().Do(service.ResendImageData)
    s.Every(config.ForwardConf.RetryInterval).Minutes().StartImmediately().Do(service.ResendImageData)
    s.Every(config.ForwardConf.ReportInterval).Second().StartImmediately().Do(service.DeviceInfoReportTask)
    s.StartAsync()
models/cache.go
@@ -25,7 +25,7 @@
}
func (c *Cache) UpdateRetryCount() error {
    return db.Table(c.TableName()).Update("retry", c.Retry+1).Where("id = ?", c.Id).Error
    return db.Table(c.TableName()).Where("id = ?", c.Id).Update("retry", c.Retry+1).Error
}
func (c *Cache) Delete() error {
service/resend.go
@@ -13,8 +13,8 @@
    for _, c := range cacheItems {
        if !util.SendData([]byte(c.Data), config.ForwardConf.SyncServer) {
            logger.Warn("The data resend failed. retry count %d", c.Retry)
            c.UpdateRetryCount()
            logger.Warn("The data resend failed. retry count %d", c.Retry+1)
        } else {
            c.Delete()
            logger.Debug("The data resend successful.")