apkipa 1 vecka sedan
förälder
incheckning
5a26fc6688
2 ändrade filer med 6 tillägg och 3 borttagningar
  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

@@ -55,8 +55,9 @@ type AppInitConfig struct {
 		Table string `mapstructure:"table"`
 	} `mapstructure:"stck"`
 	Main struct {
-		UploadRetryMaxTimes     int `mapstructure:"uploadRetryMaxTimes"`
-		FailedRetryDelaySeconds int `mapstructure:"failedRetryDelaySeconds"`
+		UploadRetryMaxTimes        int `mapstructure:"uploadRetryMaxTimes"`
+		FailedRetryDelaySeconds    int `mapstructure:"failedRetryDelaySeconds"`
+		NotifyToUploadDelaySeconds int `mapstructure:"notifyToUploadDelaySeconds"`
 	} `mapstructure:"main"`
 }
 
@@ -106,6 +107,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) {
@@ -378,7 +380,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)