Skip to content

Commit 6a03396

Browse files
author
brickzzhang
committed
[retry enhancement]
1. add retry func 2. unify charge_type name 3. modify description
1 parent 1090434 commit 6a03396

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

tencentcloud/connectivity/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package connectivity
22

33
import (
44
"fmt"
5+
56
"github.com/aws/aws-sdk-go/aws"
67
"github.com/aws/aws-sdk-go/aws/credentials"
78
"github.com/aws/aws-sdk-go/aws/endpoints"

tencentcloud/data_source_tc_sqlserver_zone_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Use this data source to query purchasable specification configuration for each availability zone in this specific region. And a maximum of 20 requests can be initiated per second for this query.
2+
Use this data source to query purchasable specification configuration for each availability zone in this specific region.
33
44
Example Usage
55
@@ -97,7 +97,7 @@ func dataSourceTencentSqlserverZoneConfig() *schema.Resource {
9797
"charge_type": {
9898
Type: schema.TypeString,
9999
Computed: true,
100-
Description: "Billing mode under this specification. POST: pay-as-you-go, PRE: pay-before-you-go, ALL: both POST and PRE.",
100+
Description: "Billing mode under this specification. Invalid values are POSTPAID_BY_HOUR, PREPAID and ALL, means both POSTPAID_BY_HOUR and PREPAID.",
101101
},
102102
},
103103
},
@@ -152,7 +152,7 @@ func dataSourceTencentSqlserverZoneConfigRead(d *schema.ResourceData, meta inter
152152
specinfoConfig["min_storage_size"] = specinfoItem.MinStorage
153153
specinfoConfig["max_storage_size"] = specinfoItem.MaxStorage
154154
specinfoConfig["qps"] = specinfoItem.QPS
155-
specinfoConfig["charge_type"] = specinfoItem.PayModeStatus
155+
specinfoConfig["charge_type"] = SQLSERVER_CHARGE_TYPE_NAME[*specinfoItem.PayModeStatus]
156156

157157
specinfoConfigs = append(specinfoConfigs, specinfoConfig)
158158
}

tencentcloud/extension_sqlserver.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package tencentcloud
2+
3+
const (
4+
SQLSERVER_CHARGE_TYPE_PREPAID = "PREPAID"
5+
SQLSERVER_CHARGE_TYPE_POSTPAID = "POSTPAID_BY_HOUR"
6+
)
7+
8+
var SQLSERVER_CHARGE_TYPE_NAME = map[string]string{
9+
"PRE": SQLSERVER_CHARGE_TYPE_PREPAID,
10+
"POST": SQLSERVER_CHARGE_TYPE_POSTPAID,
11+
"ALL": "ALL",
12+
}

tencentcloud/service_tencentcloud_sqlserver.go

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package tencentcloud
22

33
import (
44
"context"
5+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
56
"log"
67

78
sqlserver "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sqlserver/v20180328"
@@ -23,8 +24,18 @@ func (me *SqlserverService) DescribeZones(ctx context.Context) (zoneInfoList []*
2324
logId, request.GetAction(), request.ToJsonString(), errRet.Error())
2425
}
2526
}()
26-
ratelimit.Check(request.GetAction())
27-
response, err := me.client.UseSqlserverClient().DescribeZones(request)
27+
28+
var response *sqlserver.DescribeZonesResponse
29+
err := resource.Retry(10*readRetryTimeout, func() *resource.RetryError {
30+
ratelimit.Check(request.GetAction())
31+
result, e := me.client.UseSqlserverClient().DescribeZones(request)
32+
if e != nil {
33+
log.Printf("[CRITAL]%s DescribeZones fail, reason:%s\n", logId, e.Error())
34+
return retryError(e)
35+
}
36+
response = result
37+
return nil
38+
})
2839
if err != nil {
2940
errRet = err
3041
return
@@ -46,8 +57,18 @@ func (me *SqlserverService) DescribeProductConfig(ctx context.Context, zone stri
4657
logId, request.GetAction(), request.ToJsonString(), errRet.Error())
4758
}
4859
}()
49-
ratelimit.Check(request.GetAction())
50-
response, err := me.client.UseSqlserverClient().DescribeProductConfig(request)
60+
61+
var response *sqlserver.DescribeProductConfigResponse
62+
err := resource.Retry(10*readRetryTimeout, func() *resource.RetryError {
63+
ratelimit.Check(request.GetAction())
64+
result, e := me.client.UseSqlserverClient().DescribeProductConfig(request)
65+
if e != nil {
66+
log.Printf("[CRITAL]%s DescribeProductConfig fail, reason:%s\n", logId, e.Error())
67+
return retryError(e)
68+
}
69+
response = result
70+
return nil
71+
})
5172
if err != nil {
5273
errRet = err
5374
return

website/docs/d/sqlserver_zone_config.html.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ layout: "tencentcloud"
33
page_title: "TencentCloud: tencentcloud_sqlserver_zone_config"
44
sidebar_current: "docs-tencentcloud-datasource-sqlserver_zone_config"
55
description: |-
6-
Use this data source to query purchasable specification configuration for each availability zone in this specific region. And a maximum of 20 requests can be initiated per second for this query.
6+
Use this data source to query purchasable specification configuration for each availability zone in this specific region.
77
---
88

99
# tencentcloud_sqlserver_zone_config
1010

11-
Use this data source to query purchasable specification configuration for each availability zone in this specific region. And a maximum of 20 requests can be initiated per second for this query.
11+
Use this data source to query purchasable specification configuration for each availability zone in this specific region.
1212

1313
## Example Usage
1414

@@ -30,7 +30,7 @@ In addition to all arguments above, the following attributes are exported:
3030
* `zone_list` - A list of availability zones. Each element contains the following attributes:
3131
* `availability_zone` - Alphabet ID of availability zone.
3232
* `specinfo_list` - A list of specinfo configurations for the specific availability zone. Each element contains the following attributes:
33-
* `charge_type` - Billing mode under this specification. POST: pay-as-you-go, PRE: pay-before-you-go, ALL: both POST and PRE.
33+
* `charge_type` - Billing mode under this specification. Invalid values are POSTPAID_BY_HOUR, PREPAID and ALL, means both POSTPAID_BY_HOUR and PREPAID.
3434
* `cpu` - Number of CPU cores.
3535
* `db_version_name` - Version name corresponding to the db_version field.
3636
* `db_version` - Database version information. Valid values: 2008R2 (SQL Server 2008 Enterprise), 2012SP3 (SQL Server 2012 Enterprise), 2016SP1 (SQL Server 2016 Enterprise), 201602 (SQL Server 2016 Standard), 2017 (SQL Server 2017 Enterprise).

0 commit comments

Comments
 (0)