Skip to content

Commit 0bd9946

Browse files
authored
fix(teo): [122175327] Add retry query (#3192)
* fix(teo): [122175327] Add retry query * feat: add changelog
1 parent bf9ec11 commit 0bd9946

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

.changelog/3192.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_teo_l7_acc_rule: Add retry query
3+
```

tencentcloud/services/teo/service_tencentcloud_teo.go

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (me *TeoService) DescribeTeoZone(ctx context.Context, zoneId string) (zone
7777
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
7878
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
7979

80-
if response == nil || len(response.Response.Zones) < 1 {
80+
if response == nil || response.Response == nil || len(response.Response.Zones) < 1 {
8181
break
8282
}
8383
instances = append(instances, response.Response.Zones...)
@@ -175,7 +175,7 @@ func (me *TeoService) DescribeTeoOriginGroup(ctx context.Context,
175175
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
176176
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
177177

178-
if response == nil || len(response.Response.OriginGroups) < 1 {
178+
if response == nil || response.Response == nil || len(response.Response.OriginGroups) < 1 {
179179
break
180180
}
181181
originGroups = append(originGroups, response.Response.OriginGroups...)
@@ -404,7 +404,7 @@ func (me *TeoService) DescribeTeoApplicationProxy(ctx context.Context,
404404
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
405405
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
406406

407-
if response == nil || len(response.Response.ApplicationProxies) < 1 {
407+
if response == nil || response.Response == nil || len(response.Response.ApplicationProxies) < 1 {
408408
break
409409
}
410410
instances = append(instances, response.Response.ApplicationProxies...)
@@ -497,7 +497,7 @@ func (me *TeoService) DescribeTeoApplicationProxyRule(ctx context.Context,
497497
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
498498
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
499499

500-
if len(response.Response.ApplicationProxies) < 1 {
500+
if response.Response == nil || len(response.Response.ApplicationProxies) < 1 {
501501
return
502502
}
503503
for _, v := range response.Response.ApplicationProxies[0].ApplicationProxyRules {
@@ -570,6 +570,10 @@ func (me *TeoService) DescribeTeoZoneSetting(ctx context.Context, zoneId string)
570570
}
571571
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
572572
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
573+
574+
if response.Response == nil {
575+
return
576+
}
573577
zoneSetting = response.Response.ZoneSetting
574578
return
575579
}
@@ -622,7 +626,7 @@ func (me *TeoService) DescribeTeoDefaultCertificate(ctx context.Context,
622626
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
623627
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
624628

625-
if response == nil || len(response.Response.DefaultServerCertInfo) < 1 {
629+
if response == nil || response.Response == nil || len(response.Response.DefaultServerCertInfo) < 1 {
626630
break
627631
}
628632
certificates = append(certificates, response.Response.DefaultServerCertInfo...)
@@ -674,7 +678,7 @@ func (me *TeoService) DescribeTeoZoneAvailablePlansByFilter(ctx context.Context,
674678
}
675679
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
676680

677-
if len(response.Response.PlanInfo) < 1 {
681+
if response.Response == nil || len(response.Response.PlanInfo) < 1 {
678682
return
679683
}
680684

@@ -714,6 +718,10 @@ func (me *TeoService) DescribeTeoRuleEnginePriority(ctx context.Context,
714718
}
715719
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
716720
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
721+
722+
if response.Response == nil {
723+
return
724+
}
717725
ruleEnginePriority = response.Response.RuleItems
718726
return
719727
}
@@ -747,7 +755,7 @@ func (me *TeoService) DescribeTeoRuleEngineSettingsByFilter(ctx context.Context,
747755
}
748756
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
749757

750-
if len(response.Response.Actions) < 1 {
758+
if response.Response == nil || len(response.Response.Actions) < 1 {
751759
return
752760
}
753761

@@ -868,6 +876,10 @@ func (me *TeoService) DescribeIdentifications(ctx context.Context, domain string
868876
}
869877
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
870878

879+
if response.Response == nil {
880+
return nil, nil
881+
}
882+
871883
identifications = response.Response.Identifications
872884
return
873885
}
@@ -964,7 +976,7 @@ func (me *TeoService) DescribeTeoApplicationProxyRuleById(ctx context.Context, r
964976
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
965977

966978
var tmpRet *teo.ApplicationProxy
967-
if len(response.Response.ApplicationProxies) < 1 {
979+
if response.Response == nil || len(response.Response.ApplicationProxies) < 1 {
968980
return
969981
}
970982

@@ -1113,7 +1125,7 @@ func (me *TeoService) DescribeTeoRuleEngineById(ctx context.Context, zoneId stri
11131125
}
11141126
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
11151127

1116-
if len(response.Response.RuleItems) < 1 {
1128+
if response.Response == nil || len(response.Response.RuleItems) < 1 {
11171129
return
11181130
}
11191131

@@ -1215,7 +1227,7 @@ func (me *TeoService) DescribeTeoCertificateConfigById(ctx context.Context, zone
12151227
}
12161228
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
12171229

1218-
if len(response.Response.AccelerationDomains) < 1 {
1230+
if response.Response == nil || len(response.Response.AccelerationDomains) < 1 {
12191231
return
12201232
}
12211233

@@ -1257,7 +1269,7 @@ func (me *TeoService) DescribeTeoL4ProxyById(ctx context.Context, zoneId string,
12571269
}
12581270
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
12591271

1260-
if len(response.Response.L4Proxies) < 1 {
1272+
if response.Response == nil || len(response.Response.L4Proxies) < 1 {
12611273
return
12621274
}
12631275

@@ -1299,7 +1311,7 @@ func (me *TeoService) DescribeTeoRealtimeLogDeliveryById(ctx context.Context, zo
12991311
}
13001312
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
13011313

1302-
if len(response.Response.RealtimeLogDeliveryTasks) < 1 {
1314+
if response.Response == nil || len(response.Response.RealtimeLogDeliveryTasks) < 1 {
13031315
return
13041316
}
13051317

@@ -1371,7 +1383,7 @@ func (me *TeoService) DescribeTeoFunctionById(ctx context.Context, zoneId string
13711383
}
13721384
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
13731385

1374-
if len(response.Response.Functions) < 1 {
1386+
if response.Response == nil || len(response.Response.Functions) < 1 {
13751387
return
13761388
}
13771389

@@ -1415,7 +1427,7 @@ func (me *TeoService) DescribeTeoFunctionRuleById(ctx context.Context, zoneId st
14151427
}
14161428
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
14171429

1418-
if len(response.Response.FunctionRules) < 1 {
1430+
if response.Response == nil || len(response.Response.FunctionRules) < 1 {
14191431
return
14201432
}
14211433

@@ -1590,6 +1602,7 @@ func (me *TeoService) DescribeTeoL7AccRuleById(ctx context.Context, zoneId strin
15901602
logId := tccommon.GetLogId(ctx)
15911603

15921604
request := teov20220901.NewDescribeL7AccRulesRequest()
1605+
response := teov20220901.NewDescribeL7AccRulesResponse()
15931606
request.ZoneId = helper.String(zoneId)
15941607

15951608
defer func() {
@@ -1600,13 +1613,25 @@ func (me *TeoService) DescribeTeoL7AccRuleById(ctx context.Context, zoneId strin
16001613

16011614
ratelimit.Check(request.GetAction())
16021615

1603-
response, err := me.client.UseTeoV20220901Client().DescribeL7AccRules(request)
1616+
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
1617+
result, e := me.client.UseTeoV20220901Client().DescribeL7AccRules(request)
1618+
if e != nil {
1619+
return tccommon.RetryError(e)
1620+
}
1621+
response = result
1622+
return nil
1623+
})
16041624
if err != nil {
16051625
errRet = err
16061626
return
16071627
}
1628+
16081629
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
16091630

1631+
if response == nil {
1632+
return
1633+
}
1634+
16101635
ret = response.Response
16111636
return
16121637
}

0 commit comments

Comments
 (0)