From e26edffca447fb8e044f7b9d1e7c9683e8fc703e Mon Sep 17 00:00:00 2001 From: gazebo Date: Sat, 30 Jun 2018 07:58:09 +0800 Subject: [PATCH] - refactor refresh config logic. --- business/tasks/configrefresh.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/business/tasks/configrefresh.go b/business/tasks/configrefresh.go index e9a798222..1a410b948 100644 --- a/business/tasks/configrefresh.go +++ b/business/tasks/configrefresh.go @@ -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)