中级
实现服务健康检查与摘除
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
service_registry_csv = open_url(____).read()
import pandas as pd
from io import StringIO
registry = pd.read_csv(StringIO(____)).copy()
def health_check(____):
idx = registry[registry['____']==instance_id].index
if idx.empty: return False
registry.loc[idx[____],'____'] = '____' if simulate_healthy else '____'
return True
def get_healthy(____):
return registry[(____) & (____)]['____'].tolist()
print(____)
for svc in registry['____'].unique():
print(____)
health_check(____)
health_check(____)
health_check(____)
print(____)
for svc in registry['____'].unique():
healthy = get_healthy(____)
alert = '____' if not healthy else '____'
print(____)
示例
输入
solve()
期望输出
初始健康实例: user-service: ['user-1', 'user-2', 'user-3'] product-service: ['prod-1', 'prod-3'] order-service: ['order-1', 'order-2'] payment-service: ['pay-1', 'pay-2'] search-service: ['search-1', 'search-2'] 更新后: user-service: ['user-1', 'user-2', 'user-3'] product-service: ['prod-3'] order-service: ['order-2'] payment-service: ['pay-1', 'pay-2'] search-service: ['search-1', 'search-2']
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199