- refactor refresh config logic.

This commit is contained in:
gazebo
2018-06-30 07:58:09 +08:00
parent 2795271dd6
commit e26edffca4

View File

@@ -35,7 +35,6 @@ func RefreshConfig(configKey string, expiresTime time.Duration, configGetter fun
if sleepGap > maxRefreshGap {
sleepGap = maxRefreshGap
}
for {
curConfig := &models.Config{
Thirdparty: configKey,
@@ -56,8 +55,6 @@ func RefreshConfig(configKey string, expiresTime time.Duration, configGetter fun
if curConfig.Date <= latestTimeStr {
curConfig.Token = configGetter()
handleType = 1
} else {
configSetter(curConfig.Token)
}
}
@@ -75,11 +72,7 @@ func RefreshConfig(configKey string, expiresTime time.Duration, configGetter fun
if err != nil || num == 0 {
globals.SugarLogger.Errorf("db error:%v, num:%d", err, num)
} else {
if configKey == "wechat" {
globals2.FreshFoodAPI.AccessFreshFood("weixin/accesstoken/update", nil)
} else if configKey == "eleme" {
globals2.FreshFoodAPI.AccessFreshFood("eleme/token/update", nil)
}
configSetter(curConfig.Token)
}
}
time.Sleep(sleepGap)