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