- refactor refresh config logic.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user