sycommon-python-lib 0.2.0b21__tar.gz → 0.2.0b23__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/PKG-INFO +1 -1
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/pyproject.toml +1 -1
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_pool.py +24 -4
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/nacos_heartbeat_manager.py +29 -6
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/nacos_service_discovery.py +9 -1
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon_python_lib.egg-info/PKG-INFO +1 -1
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/README.md +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/setup.cfg +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/command/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/command/cli.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/command/console.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/command/models.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/command/project.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/command/utils.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/01_basic_agent.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/02_tool_agent.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/03_structured_output.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/04_memory_agent.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/05_streaming.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/06_multi_agent.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/07_skills_agent.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/08_middleware.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/09_interrupt.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/10_custom_llm.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/11_complex_workflow.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/12_batch_processing.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/01_basic_monitoring.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/02_permission_control.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/03_tool_skill_filter.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/04_caching_retry.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/05_sanitization.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/06_tracking.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/07_advanced.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/08_progressive_skills.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/examples/middleware/override_examples.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/get_agent.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/Config.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/DatabaseConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/ElasticsearchConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/EmbeddingConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/LLMConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/LangfuseConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/MQConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/RedisConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/RerankerConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/SentryConfig.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/database/async_base_db_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/database/async_database_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/database/base_db_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/database/database_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/database/elasticsearch_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/database/redis_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/health/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/health/health_check.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/health/metrics.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/health/ping.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/embedding.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/get_llm.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/llm_logger.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/llm_tokens.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/struct_token.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/sy_langfuse.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/token_usage_es_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/token_usage_mysql_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/usage_token.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/async_sql_logger.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/kafka_log.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/logger_levels.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/logger_wrapper.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/sql_logger.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/context.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/cors.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/docs.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/exception.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/middleware.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/monitor_memory.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/mq.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/timeout.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/traceid.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/base_http.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/log.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/mqlistener_config.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/mqmsg_model.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/mqsend_config.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/sso_user.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/token_usage.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/token_usage_mysql.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/notice/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/notice/uvicorn_monitor.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_client.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_service_client_manager.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_service_connection_monitor.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_service_consumer_manager.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_service_core.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_service_producer_manager.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/sentry/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/sentry/sy_sentry.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/services.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/sse/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/sse/event.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/sse/sse.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/example.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/example2.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/feign.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/feign_client.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/nacos_client_base.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/nacos_config_manager.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/nacos_service.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/nacos_service_registration.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/param.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tests/test_email.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tests/test_mq.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/__init__.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/async_utils.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/docs.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/env.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/merge_headers.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/snowflake.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/syemail.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/timing.py +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon_python_lib.egg-info/SOURCES.txt +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon_python_lib.egg-info/dependency_links.txt +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon_python_lib.egg-info/entry_points.txt +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon_python_lib.egg-info/requires.txt +0 -0
- {sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon_python_lib.egg-info/top_level.txt +0 -0
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/rabbitmq/rabbitmq_pool.py
RENAMED
|
@@ -71,11 +71,13 @@ class RabbitMQConnectionPool:
|
|
|
71
71
|
self._alert_sent: bool = False # 是否已发送断连告警
|
|
72
72
|
self._reconnect_attempts: int = 0 # 当前重连尝试次数
|
|
73
73
|
self._disconnect_count: int = 0 # 累计断开次数
|
|
74
|
+
self._consecutive_success: int = 0 # 连续成功次数,用于确认恢复
|
|
74
75
|
|
|
75
76
|
async def is_alive(self) -> bool:
|
|
76
77
|
"""对外暴露的连接存活状态(带心跳重试机制)
|
|
77
78
|
|
|
78
79
|
心跳检测失败时不会立即判定为断开,而是重试3次后才断开。
|
|
80
|
+
恢复通知需要连续成功3次确认,避免短暂恢复后又断开的波动情况。
|
|
79
81
|
"""
|
|
80
82
|
if self._is_shutdown:
|
|
81
83
|
return False
|
|
@@ -85,6 +87,7 @@ class RabbitMQConnectionPool:
|
|
|
85
87
|
# 基础连接检查
|
|
86
88
|
if self._connection is None or self._connection.is_closed:
|
|
87
89
|
self._heartbeat_fail_count += 1
|
|
90
|
+
self._consecutive_success = 0 # 失败时重置连续成功计数
|
|
88
91
|
logger.warning(
|
|
89
92
|
f"⚠️ [HEARTBEAT] 连接已断开 (失败计数: {self._heartbeat_fail_count}/{self.HEARTBEAT_RETRY_COUNT})"
|
|
90
93
|
)
|
|
@@ -94,6 +97,9 @@ class RabbitMQConnectionPool:
|
|
|
94
97
|
if not self._alert_sent:
|
|
95
98
|
self._alert_sent = True
|
|
96
99
|
self._disconnect_count += 1
|
|
100
|
+
logger.warning(
|
|
101
|
+
f"📊 [MQ_ALERT] 发送断连告警,累计断开: {self._disconnect_count}次,重连尝试: {self._reconnect_attempts}次"
|
|
102
|
+
)
|
|
97
103
|
asyncio.create_task(send_mq_disconnect_alert(
|
|
98
104
|
error_msg="心跳检测连续失败,连接已断开",
|
|
99
105
|
host=self._current_host,
|
|
@@ -109,14 +115,19 @@ class RabbitMQConnectionPool:
|
|
|
109
115
|
try:
|
|
110
116
|
if self._internal_channel is None or self._internal_channel.is_closed:
|
|
111
117
|
self._internal_channel = await self._connection.channel()
|
|
112
|
-
#
|
|
118
|
+
# 探活成功
|
|
113
119
|
self._heartbeat_fail_count = 0
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
self._consecutive_success += 1
|
|
121
|
+
|
|
122
|
+
# 如果之前发送过告警,心跳成功一次即发送恢复通知
|
|
123
|
+
if self._alert_sent and self._consecutive_success >= 1:
|
|
116
124
|
self._alert_sent = False
|
|
117
125
|
saved_reconnect_attempts = self._reconnect_attempts
|
|
118
126
|
saved_disconnect_count = self._disconnect_count
|
|
119
127
|
self._reconnect_attempts = 0
|
|
128
|
+
logger.info(
|
|
129
|
+
f"✅ [MQ_RECOVERED] 连接已稳定恢复(连续成功{self._consecutive_success}次),发送恢复通知"
|
|
130
|
+
)
|
|
120
131
|
asyncio.create_task(send_mq_disconnect_alert(
|
|
121
132
|
error_msg="连接已恢复",
|
|
122
133
|
host=self._current_host,
|
|
@@ -128,6 +139,7 @@ class RabbitMQConnectionPool:
|
|
|
128
139
|
return True
|
|
129
140
|
except Exception as e:
|
|
130
141
|
self._heartbeat_fail_count += 1
|
|
142
|
+
self._consecutive_success = 0 # 异常时重置连续成功计数
|
|
131
143
|
logger.warning(
|
|
132
144
|
f"⚠️ [HEARTBEAT] 连接探活失败: {e} (失败计数: {self._heartbeat_fail_count}/{self.HEARTBEAT_RETRY_COUNT})"
|
|
133
145
|
)
|
|
@@ -137,6 +149,9 @@ class RabbitMQConnectionPool:
|
|
|
137
149
|
if not self._alert_sent:
|
|
138
150
|
self._alert_sent = True
|
|
139
151
|
self._disconnect_count += 1
|
|
152
|
+
logger.warning(
|
|
153
|
+
f"📊 [MQ_ALERT] 发送断连告警(异常),累计断开: {self._disconnect_count}次,重连尝试: {self._reconnect_attempts}次"
|
|
154
|
+
)
|
|
140
155
|
asyncio.create_task(send_mq_disconnect_alert(
|
|
141
156
|
error_msg=str(e),
|
|
142
157
|
host=self._current_host,
|
|
@@ -230,12 +245,17 @@ class RabbitMQConnectionPool:
|
|
|
230
245
|
self._initialized = False
|
|
231
246
|
raise ConnectionError("所有 RabbitMQ 节点连接失败") from last_error
|
|
232
247
|
|
|
233
|
-
#
|
|
248
|
+
# 重连成功
|
|
249
|
+
self._consecutive_success = 1 # 重连成功算第1次成功
|
|
250
|
+
# 发送恢复通知(重连成功后直接发送,因为是主动重建连接)
|
|
234
251
|
if self._alert_sent:
|
|
235
252
|
self._alert_sent = False
|
|
236
253
|
saved_reconnect_attempts = self._reconnect_attempts
|
|
237
254
|
saved_disconnect_count = self._disconnect_count
|
|
238
255
|
self._reconnect_attempts = 0
|
|
256
|
+
logger.info(
|
|
257
|
+
f"✅ [MQ_RECONNECT_OK] 重连成功,发送恢复通知,累计断开: {saved_disconnect_count}次"
|
|
258
|
+
)
|
|
239
259
|
asyncio.create_task(send_mq_disconnect_alert(
|
|
240
260
|
error_msg="连接重连成功",
|
|
241
261
|
host=self._current_host,
|
|
@@ -15,13 +15,14 @@ def send_nacos_alert_sync(
|
|
|
15
15
|
is_recovered: bool = False
|
|
16
16
|
):
|
|
17
17
|
"""同步方式发送 Nacos 告警(用于在线程中调用)"""
|
|
18
|
+
alert_type = "恢复" if is_recovered else "断开"
|
|
18
19
|
try:
|
|
19
20
|
# 创建新的事件循环
|
|
20
21
|
loop = asyncio.new_event_loop()
|
|
21
22
|
asyncio.set_event_loop(loop)
|
|
22
23
|
try:
|
|
23
24
|
from sycommon.notice.uvicorn_monitor import send_nacos_disconnect_alert
|
|
24
|
-
loop.run_until_complete(send_nacos_disconnect_alert(
|
|
25
|
+
result = loop.run_until_complete(send_nacos_disconnect_alert(
|
|
25
26
|
error_msg=error_msg,
|
|
26
27
|
service_name=service_name,
|
|
27
28
|
host=host,
|
|
@@ -29,10 +30,14 @@ def send_nacos_alert_sync(
|
|
|
29
30
|
fail_count=fail_count,
|
|
30
31
|
is_recovered=is_recovered
|
|
31
32
|
))
|
|
33
|
+
if result:
|
|
34
|
+
SYLogger.info(f"Nacos {alert_type}告警发送成功")
|
|
35
|
+
else:
|
|
36
|
+
SYLogger.warning(f"Nacos {alert_type}告警发送返回空结果")
|
|
32
37
|
finally:
|
|
33
38
|
loop.close()
|
|
34
39
|
except Exception as e:
|
|
35
|
-
SYLogger.
|
|
40
|
+
SYLogger.error(f"发送 Nacos {alert_type}告警失败: {e}")
|
|
36
41
|
|
|
37
42
|
|
|
38
43
|
class NacosHeartbeatManager:
|
|
@@ -41,6 +46,7 @@ class NacosHeartbeatManager:
|
|
|
41
46
|
# 告警状态(类级别)
|
|
42
47
|
_alert_sent: bool = False # 是否已发送断连告警
|
|
43
48
|
_disconnect_count: int = 0 # 累计断开次数
|
|
49
|
+
_alert_fail_count: int = 0 # 发送告警时的连续失败次数(用于恢复通知)
|
|
44
50
|
|
|
45
51
|
def __init__(self, client_base: NacosClientBase, registration: NacosServiceRegistration, heartbeat_interval: int = 15):
|
|
46
52
|
self.client_base = client_base
|
|
@@ -89,6 +95,7 @@ class NacosHeartbeatManager:
|
|
|
89
95
|
)
|
|
90
96
|
|
|
91
97
|
consecutive_fail = 0
|
|
98
|
+
consecutive_success = 0 # 连续成功次数,用于确认恢复
|
|
92
99
|
|
|
93
100
|
while not self.client_base._shutdown_event.is_set():
|
|
94
101
|
# 记录本次心跳开始时间,用于精确计算剩余等待时间
|
|
@@ -101,17 +108,21 @@ class NacosHeartbeatManager:
|
|
|
101
108
|
SYLogger.warning(
|
|
102
109
|
f"nacos:服务未注册,跳过心跳 - 线程ID: {thread_ident}")
|
|
103
110
|
consecutive_fail = 0
|
|
111
|
+
consecutive_success = 0
|
|
104
112
|
else:
|
|
105
113
|
success = self.send_heartbeat()
|
|
106
114
|
if success:
|
|
107
115
|
consecutive_fail = 0
|
|
116
|
+
consecutive_success += 1
|
|
108
117
|
self._last_heartbeat_time = time.time()
|
|
109
118
|
SYLogger.info(
|
|
110
|
-
f"nacos:心跳发送成功 - 间隔: {self.heartbeat_interval}
|
|
119
|
+
f"nacos:心跳发送成功 - 间隔: {self.heartbeat_interval}秒, 连续成功: {consecutive_success}次"
|
|
111
120
|
)
|
|
112
|
-
#
|
|
113
|
-
if self._alert_sent:
|
|
121
|
+
# 恢复后发送通知(心跳成功一次即恢复)
|
|
122
|
+
if self._alert_sent and consecutive_success >= 1:
|
|
123
|
+
SYLogger.info(f"nacos:检测恢复状态 - _alert_sent={self._alert_sent}, consecutive_success={consecutive_success}")
|
|
114
124
|
self._alert_sent = False
|
|
125
|
+
SYLogger.info(f"nacos:心跳已稳定恢复,发送恢复通知")
|
|
115
126
|
send_nacos_alert_sync(
|
|
116
127
|
error_msg="心跳恢复正常",
|
|
117
128
|
service_name=self.registration.service_name,
|
|
@@ -121,6 +132,7 @@ class NacosHeartbeatManager:
|
|
|
121
132
|
is_recovered=True
|
|
122
133
|
)
|
|
123
134
|
else:
|
|
135
|
+
consecutive_success = 0 # 失败时重置连续成功计数
|
|
124
136
|
consecutive_fail += 1
|
|
125
137
|
self._heartbeat_fail_count += 1
|
|
126
138
|
SYLogger.warning(
|
|
@@ -133,8 +145,13 @@ class NacosHeartbeatManager:
|
|
|
133
145
|
|
|
134
146
|
# 连续失败3次后发送告警(仅发送一次)
|
|
135
147
|
if consecutive_fail >= 3 and not self._alert_sent:
|
|
148
|
+
SYLogger.info(f"nacos:准备发送断开告警 - consecutive_fail={consecutive_fail}, _alert_sent={self._alert_sent}")
|
|
136
149
|
self._alert_sent = True
|
|
137
150
|
self._disconnect_count += 1
|
|
151
|
+
self._alert_fail_count = consecutive_fail # 记录告警时的失败次数
|
|
152
|
+
SYLogger.warning(
|
|
153
|
+
f"nacos:心跳连续失败{consecutive_fail}次,发送告警通知,累计断开: {self._disconnect_count}次"
|
|
154
|
+
)
|
|
138
155
|
send_nacos_alert_sync(
|
|
139
156
|
error_msg=f"心跳连续失败{consecutive_fail}次",
|
|
140
157
|
service_name=self.registration.service_name,
|
|
@@ -146,6 +163,7 @@ class NacosHeartbeatManager:
|
|
|
146
163
|
|
|
147
164
|
except Exception as e:
|
|
148
165
|
consecutive_fail += 1
|
|
166
|
+
consecutive_success = 0 # 异常时重置连续成功计数
|
|
149
167
|
self._heartbeat_fail_count += 1
|
|
150
168
|
SYLogger.error(
|
|
151
169
|
f"nacos:心跳异常: {str(e)}, 连续失败: {consecutive_fail}次")
|
|
@@ -154,6 +172,10 @@ class NacosHeartbeatManager:
|
|
|
154
172
|
if consecutive_fail >= 3 and not self._alert_sent:
|
|
155
173
|
self._alert_sent = True
|
|
156
174
|
self._disconnect_count += 1
|
|
175
|
+
self._alert_fail_count = consecutive_fail # 记录告警时的失败次数
|
|
176
|
+
SYLogger.warning(
|
|
177
|
+
f"nacos:心跳异常连续失败{consecutive_fail}次,发送告警通知,累计断开: {self._disconnect_count}次"
|
|
178
|
+
)
|
|
157
179
|
send_nacos_alert_sync(
|
|
158
180
|
error_msg=f"心跳异常: {str(e)}",
|
|
159
181
|
service_name=self.registration.service_name,
|
|
@@ -215,7 +237,8 @@ class NacosHeartbeatManager:
|
|
|
215
237
|
"version": self.registration.version} if self.registration.version else None
|
|
216
238
|
)
|
|
217
239
|
|
|
218
|
-
|
|
240
|
+
# 心跳成功:只要返回结果就认为成功(不依赖 lightBeatEnabled 字段)
|
|
241
|
+
if result:
|
|
219
242
|
SYLogger.info(f"nacos:心跳发送成功,Nacos返回: {result}")
|
|
220
243
|
return True
|
|
221
244
|
else:
|
|
@@ -203,9 +203,17 @@ class NacosServiceDiscovery:
|
|
|
203
203
|
)
|
|
204
204
|
registration.verify_registration()
|
|
205
205
|
else:
|
|
206
|
-
#
|
|
206
|
+
# 服务正常,重置告警状态并发送恢复通知
|
|
207
207
|
if self._service_alert_sent and current_registered:
|
|
208
208
|
self._service_alert_sent = False
|
|
209
|
+
SYLogger.info(f"nacos:服务已恢复正常,发送恢复通知")
|
|
210
|
+
send_nacos_service_alert_sync(
|
|
211
|
+
error_msg="服务实例已恢复正常",
|
|
212
|
+
service_name=registration.service_name,
|
|
213
|
+
host=f"{registration.real_ip}:{registration.port}",
|
|
214
|
+
is_service_down=False,
|
|
215
|
+
disconnect_count=self._disconnect_count
|
|
216
|
+
)
|
|
209
217
|
|
|
210
218
|
self.client_base._shutdown_event.wait(check_interval)
|
|
211
219
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/agent/get_agent.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/DatabaseConfig.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/EmbeddingConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/LLMConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/LangfuseConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/MQConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/RedisConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/RerankerConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/SentryConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/config/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/database/redis_service.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/health/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/health/health_check.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/health/metrics.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/llm_logger.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/llm_tokens.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/struct_token.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/sy_langfuse.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/llm/usage_token.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/kafka_log.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/logger_levels.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/logger_wrapper.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/logging/sql_logger.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/context.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/cors.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/docs.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/exception.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/middleware.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/timeout.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/middleware/traceid.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/base_http.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/mqmsg_model.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/mqsend_config.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/sso_user.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/models/token_usage.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/notice/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/notice/uvicorn_monitor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/sentry/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/sentry/sy_sentry.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/example.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/example2.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/feign_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/synacos/nacos_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tests/test_email.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/async_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/merge_headers.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.2.0b21 → sycommon_python_lib-0.2.0b23}/src/sycommon/tools/snowflake.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|