Skip to content

Commit e53ff6c

Browse files
author
张哲铭
committed
feat: security group add limiter
1 parent c86ee58 commit e53ff6c

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

common/common_volcengine_limit.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func init() {
3131
Limiter: rate.NewLimiter(4, 10),
3232
Semaphore: semaphore.NewWeighted(10),
3333
},
34+
"vpc.DescribeSecurityGroups.2020-04-01": {
35+
Limiter: rate.NewLimiter(4, 10),
36+
Semaphore: semaphore.NewWeighted(10),
37+
},
3438
}
3539
}
3640

example/securityGroup/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
resource "volcengine_security_group" "g1test1" {
22
vpc_id = "vpc-2feppmy1ugt1c59gp688n1fld"
3-
project_name = "yuwenhao"
3+
project_name = "default"
44
}

volcengine/privatelink/vpc_endpoint/service_volcengine_privatelink_vpc_endpoint.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (s *VolcengineVpcEndpointService) CreateResource(resourceData *schema.Resou
168168
req := map[string]interface{}{
169169
"SecurityGroupIds.1": securityGroupId,
170170
}
171-
resp, err := s.Client.VpcClient.DescribeSecurityGroupsCommon(&req)
171+
resp, err := s.Client.UniversalClient.DoCall(getVpcUniversalInfo(action), &req)
172172
if err != nil {
173173
return false, err
174174
}
@@ -329,3 +329,13 @@ func getUniversalInfo(actionName string) ve.UniversalInfo {
329329
ContentType: ve.Default,
330330
}
331331
}
332+
333+
func getVpcUniversalInfo(actionName string) ve.UniversalInfo {
334+
return ve.UniversalInfo{
335+
ServiceName: "vpc",
336+
Version: "2020-04-01",
337+
HttpMethod: ve.GET,
338+
ContentType: ve.Default,
339+
Action: actionName,
340+
}
341+
}

volcengine/vpc/security_group/service_volcengine_security_group.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ func (s *VolcengineSecurityGroupService) ReadResources(m map[string]interface{})
3333
ok bool
3434
)
3535
return ve.WithPageNumberQuery(m, "PageSize", "PageNumber", 20, 1, func(condition map[string]interface{}) ([]interface{}, error) {
36-
vpcClient := s.Client.VpcClient
36+
vpcClient := s.Client.UniversalClient
3737
action := "DescribeSecurityGroups"
3838
logger.Debug(logger.ReqFormat, action, condition)
3939
if condition == nil {
40-
resp, err = vpcClient.DescribeSecurityGroupsCommon(nil)
40+
resp, err = vpcClient.DoCall(getUniversalInfo(action), nil)
4141
if err != nil {
4242
return data, err
4343
}
4444
} else {
45-
resp, err = vpcClient.DescribeSecurityGroupsCommon(&condition)
45+
resp, err = vpcClient.DoCall(getUniversalInfo(action), &condition)
4646
if err != nil {
4747
return data, err
4848
}

0 commit comments

Comments
 (0)