Skip to content

Commit

Permalink
feat: CC接口限频优化 (closed #2531)
Browse files Browse the repository at this point in the history
  • Loading branch information
ping15 committed Jan 17, 2025
1 parent c4abab3 commit 7fc6799
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/backend/subscription/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,21 @@ def get_service_instance_by_inst(bk_biz_id, inst_list, module_to_topo):

# 如果module_ids只有一个,没必要使用第一种方式,一定会出现一次list_service_instance_detail查询
if len(module_ids) > 1 and random.random() < 0.5:
service_instance_ids = get_service_instance_ids(bk_biz_id, list(module_ids))
if not service_instance_ids:
return []

service_instances = batch_request(
func=CCApi.list_service_instance_detail,
params={
"bk_biz_id": int(bk_biz_id),
"with_name": True,
"no_request": True,
"service_instance_ids": get_service_instance_ids(bk_biz_id, list(module_ids)),
"service_instance_ids": service_instance_ids,
},
sort="id",
interval=constants.LIST_SERVICE_INSTANCE_DETAIL_INTERVAL,
limit=constants.LIST_SERVICE_INSTANCE_DETAIL_LIMIT,
)
else:
service_instances = batch_call(
Expand Down

0 comments on commit 7fc6799

Please sign in to comment.