"""API接口配置文件""" # API配置 API_CONFIG = { # 主要API接口 'main_api': { 'url': 'https://jsonplaceholder.typicode.com/posts', 'method': 'POST', 'headers': { 'Content-Type': 'application/json', 'User-Agent': 'Celery-Task/1.0' }, 'timeout': 30, 'body': { 'title': '每日定时任务', 'body': '这是通过配置文件设置的请求体数据', 'userId': 1 } }, # 备用API接口 'backup_api': { 'url': 'https://jsonplaceholder.typicode.com/comments', 'method': 'POST', 'headers': { 'Content-Type': 'application/json', 'User-Agent': 'Celery-Task/1.0' }, 'timeout': 30, 'body': { 'name': '备用任务', 'email': 'backup@example.com', 'body': '这是备用API的请求体' } }, # 健康检查API 'health_check': { 'url': 'https://jsonplaceholder.typicode.com/posts/1', 'method': 'GET', 'headers': { 'User-Agent': 'Celery-Task/1.0' }, 'timeout': 10, 'body': {} # GET请求通常不需要body,但可以设置查询参数 }, # GET请求示例API 'get_api': { 'url': 'https://jsonplaceholder.typicode.com/posts', 'method': 'GET', 'headers': { 'User-Agent': 'Celery-Task/1.0' }, 'timeout': 30, 'body': { 'userId': 1, # 这将作为查询参数 'limit': 10 } }, # PUT请求示例API 'put_api': { 'url': 'https://jsonplaceholder.typicode.com/posts/1', 'method': 'PUT', 'headers': { 'Content-Type': 'application/json', 'User-Agent': 'Celery-Task/1.0' }, 'timeout': 30, 'body': { 'id': 1, 'title': '更新后的标题', 'body': '这是通过PUT请求更新的内容', 'userId': 1 } } } # 重试配置 RETRY_CONFIG = { 'max_retries': 3, 'retry_delay': 60, # 重试间隔(秒) 'retry_on_status': [500, 502, 503, 504, 429] }