Skip to content

Commit 82d5cfe

Browse files
committed
Update in sync_data
1 parent b51bedc commit 82d5cfe

1 file changed

Lines changed: 4 additions & 16 deletions

File tree

aikido_zen/background_process/commands/sync_data.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,13 @@ def process_sync_data(connection_manager, data, conn, queue=None):
1313
BG Process -> Thread : Routes and config
1414
"""
1515

16-
# Sync routes
17-
routes = connection_manager.routes
18-
for route in data.get("current_routes", {}).values():
19-
route_metadata = {"method": route["method"], "route": route["path"]}
20-
if not routes.get(route_metadata):
21-
routes.initialize_route(route_metadata)
22-
existing_route = routes.get(route_metadata)
23-
24-
# Update hit count :
25-
hits_delta_since_sync = int(route.get("hits_delta_since_sync", 0))
26-
existing_route["hits"] += hits_delta_since_sync
27-
28-
# Update API Spec :
29-
update_route_info(route["apispec"], existing_route)
30-
3116
# Save middleware installed :
3217
if data.get("middleware_installed", False):
3318
connection_manager.middleware_installed = True
3419

20+
# Sync routes
21+
connection_manager.routes.increment_route(data.get("routes", {}))
22+
3523
# Sync hostnames
3624
for hostnames_entry in data.get("hostnames", list()):
3725
connection_manager.hostnames.add(
@@ -56,7 +44,7 @@ def process_sync_data(connection_manager, data, conn, queue=None):
5644
if connection_manager.conf.last_updated_at > 0:
5745
# Only report data if the config has been fetched.
5846
return {
59-
"routes": dict(connection_manager.routes.routes),
47+
"routes": connection_manager.routes.export(),
6048
"config": connection_manager.conf,
6149
}
6250
return {}

0 commit comments

Comments
 (0)