apkipa 1 semana atrás
pai
commit
671c3a7fc7
2 arquivos alterados com 6 adições e 3 exclusões
  1. 1 0
      config/application.yaml
  2. 5 3
      main.go

+ 1 - 0
config/application.yaml

@@ -18,3 +18,4 @@ nsq:
 main:
   uploadRetryMaxTimes: 20
   failedRetryDelaySeconds: 5
+  notifyToUploadDelaySeconds: 1

+ 5 - 3
main.go

@@ -63,8 +63,9 @@ type AppInitConfig struct {
 		LookupdHttpAddr string `mapstructure:"lookupdHttpAddr"`
 	} `mapstructure:"nsq"`
 	Main struct {
-		UploadRetryMaxTimes     int `mapstructure:"uploadRetryMaxTimes"`
-		FailedRetryDelaySeconds int `mapstructure:"failedRetryDelaySeconds"`
+		UploadRetryMaxTimes        int `mapstructure:"uploadRetryMaxTimes"`
+		FailedRetryDelaySeconds    int `mapstructure:"failedRetryDelaySeconds"`
+		NotifyToUploadDelaySeconds int `mapstructure:"notifyToUploadDelaySeconds"`
 	} `mapstructure:"main"`
 }
 
@@ -333,6 +334,7 @@ var appInitCfg *AppInitConfig = &AppInitConfig{}
 func initLoadConfig() {
 	viper.SetDefault("main.uploadRetryMaxTimes", 20)
 	viper.SetDefault("main.failedRetryDelaySeconds", 5)
+	viper.SetDefault("main.notifyToUploadDelaySeconds", 1)
 	viper.SetConfigFile("./config/application.yaml")
 	viper.WatchConfig()
 	viper.OnConfigChange(func(e fsnotify.Event) {
@@ -612,7 +614,7 @@ func main_worker(app AppCtx, objUploadChan *util.DChan[string]) {
 					delete(objFailCounter, key)
 					mutexObjFailCounter.Unlock()
 					// Queue the object for upload
-					objUploadChan.DelayedWrite(key, 1*time.Second)
+					objUploadChan.DelayedWrite(key, time.Duration(appInitCfg.Main.NotifyToUploadDelaySeconds)*time.Second)
 				}
 				if notifyInfo.Err != nil {
 					logger.Errorf("Bucket notification listener error: %v", notifyInfo.Err)