Selaa lähdekoodia

add retry times

supeng 2 viikkoa sitten
vanhempi
commit
68fd370cbf

+ 2 - 2
content-understanding-core/src/main/java/com/tzld/piaoquan/content/understanding/service/impl/GeminiGenerateContentAction.java

@@ -41,7 +41,7 @@ public class GeminiGenerateContentAction implements Action {
     private static final String MODEL = "gemini-2.0-flash";
     private static final Double TEMPERATURE = 1.0;
 
-    private static final Integer RETRY_TIMES = 5;
+    private static final Integer RETRY_TIMES = 10;
 
     @Autowired
     private RedisUtil redisUtil;
@@ -114,7 +114,7 @@ public class GeminiGenerateContentAction implements Action {
                 }
                 throw new RuntimeException("geminiGenerateContentAction request error", e);
             }
-        }, RETRY_TIMES, "geminiGenerateContentAction", RetryUtil::retryInterval);
+        }, RETRY_TIMES, "geminiGenerateContentAction", RetryUtil::retryIntervalLevel1);
     }
 
     private int getIndex(int size) {

+ 49 - 5
content-understanding-core/src/main/java/com/tzld/piaoquan/content/understanding/util/RetryUtil.java

@@ -87,23 +87,67 @@ public class RetryUtil {
      */
     public static long retryInterval(int i) {
         if (i == 1) {
-            return 10 * 1000L;
+            return 5 * 1000L;
         }
         if (i == 2) {
-            return 30 * 1000L;
+            return 10 * 1000L;
         }
         if (i == 3) {
-            return 60 * 1000L;
+            return 30 * 1000L;
         }
         if (i == 4) {
-            return 3 * 60 * 1000L;
+            return 60 * 1000L;
         }
         if (i == 5) {
-            return 5 * 60 * 1000L;
+            return 2 * 60 * 1000L;
         }
         if (i == 6) {
+            return 3 * 60 * 1000L;
+        }
+        if (i == 7) {
+            return 5 * 60 * 1000L;
+        }
+        if (i == 8) {
             return 10 * 60 * 1000L;
         }
+        if (i == 9) {
+            return 20 * 60 * 1000L;
+        }
+        if (i == 10) {
+            return 30 * 60 * 1000L;
+        }
+
+        return 0L;
+    }
+
+    public static long retryIntervalLevel1(int i) {
+        if (i == 1) {
+            return 1000L;
+        }
+        if (i == 2) {
+            return 3 * 1000L;
+        }
+        if (i == 3) {
+            return 5 * 1000L;
+        }
+        if (i == 4) {
+            return 8 * 1000L;
+        }
+        if (i == 5) {
+            return 10 * 1000L;
+        }
+        if (i == 6) {
+            return 10 * 1000L;
+        }
+        if (i == 8) {
+            return 20 * 1000L;
+        }
+        if (i == 9) {
+            return 20 * 1000L;
+        }
+        if (i == 10) {
+            return 20 * 1000L;
+        }
         return 0L;
     }
 }