sycommon-python-lib 0.1.15__tar.gz → 0.1.16__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.
Potentially problematic release.
This version of sycommon-python-lib might be problematic. Click here for more details.
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/PKG-INFO +1 -1
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/pyproject.toml +1 -1
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/logging/kafka_log.py +1 -1
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/rabbitmq/rabbitmq_service.py +1 -1
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/services.py +18 -17
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon_python_lib.egg-info/PKG-INFO +1 -1
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/README.md +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/setup.cfg +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/command/cli.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/Config.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/DatabaseConfig.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/EmbeddingConfig.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/LLMConfig.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/MQConfig.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/RerankerConfig.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/database/base_db_service.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/database/database_service.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/health/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/health/health_check.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/health/ping.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/logging/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/logging/logger_wrapper.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/context.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/cors.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/docs.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/exception.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/middleware.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/monitor_memory.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/mq.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/timeout.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/traceid.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/base_http.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/log.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/mqlistener_config.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/mqmsg_model.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/mqsend_config.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/sso_user.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/rabbitmq/rabbitmq_client.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/sse/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/sse/event.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/sse/sse.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/synacos/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/synacos/feign.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/synacos/nacos_service.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/tools/__init__.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/tools/docs.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/tools/snowflake.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/tools/timing.py +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon_python_lib.egg-info/SOURCES.txt +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon_python_lib.egg-info/dependency_links.txt +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon_python_lib.egg-info/entry_points.txt +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon_python_lib.egg-info/requires.txt +0 -0
- {sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon_python_lib.egg-info/top_level.txt +0 -0
|
@@ -72,7 +72,7 @@ class KafkaLogger(metaclass=SingletonMeta):
|
|
|
72
72
|
connections_max_idle_ms=540000, # 连接最大空闲时间
|
|
73
73
|
reconnect_backoff_max_ms=10000, # 增加重连退避最大时间
|
|
74
74
|
max_in_flight_requests_per_connection=1, # 限制单个连接上未确认的请求数量
|
|
75
|
-
enable_idempotence=True, # 开启幂等性
|
|
75
|
+
# enable_idempotence=True, # 开启幂等性
|
|
76
76
|
)
|
|
77
77
|
|
|
78
78
|
# 启动后台发送线程
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/rabbitmq/rabbitmq_service.py
RENAMED
|
@@ -100,7 +100,7 @@ class RabbitMQService:
|
|
|
100
100
|
f"允许创建: {create_if_not_exists}"
|
|
101
101
|
)
|
|
102
102
|
|
|
103
|
-
#
|
|
103
|
+
# 将逗号分隔的host字符串拆分为集群节点列表
|
|
104
104
|
hosts_str = mq_config.get('host', "")
|
|
105
105
|
hosts_list = [host.strip()
|
|
106
106
|
for host in hosts_str.split(',') if host.strip()]
|
|
@@ -19,6 +19,7 @@ class Services(metaclass=SingletonMeta):
|
|
|
19
19
|
_mq_tasks: List[asyncio.Task] = []
|
|
20
20
|
_instance: Optional['Services'] = None
|
|
21
21
|
_app: Optional[FastAPI] = None
|
|
22
|
+
_user_lifespan: Optional[Callable] = None
|
|
22
23
|
|
|
23
24
|
def __init__(self, config: dict, app: FastAPI):
|
|
24
25
|
if not Services._config:
|
|
@@ -54,6 +55,7 @@ class Services(metaclass=SingletonMeta):
|
|
|
54
55
|
# 保存应用实例和配置
|
|
55
56
|
cls._app = app
|
|
56
57
|
cls._config = config
|
|
58
|
+
cls._user_lifespan = app.router.lifespan_context
|
|
57
59
|
# 设置文档
|
|
58
60
|
applications.get_swagger_ui_html = custom_swagger_ui_html
|
|
59
61
|
applications.get_redoc_html = custom_redoc_html
|
|
@@ -71,20 +73,15 @@ class Services(metaclass=SingletonMeta):
|
|
|
71
73
|
if database_service:
|
|
72
74
|
cls._setup_database_static(database_service, config)
|
|
73
75
|
|
|
74
|
-
#
|
|
76
|
+
# 创建组合生命周期管理器
|
|
75
77
|
@asynccontextmanager
|
|
76
|
-
async def
|
|
77
|
-
#
|
|
78
|
+
async def combined_lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
|
79
|
+
# 1. 执行Services自身的初始化
|
|
78
80
|
instance = cls(config, app)
|
|
79
|
-
|
|
80
|
-
# 检查是否存在监听器
|
|
81
81
|
has_listeners = bool(
|
|
82
82
|
rabbitmq_listeners and len(rabbitmq_listeners) > 0)
|
|
83
|
-
|
|
84
|
-
has_senders = bool(
|
|
85
|
-
rabbitmq_senders and len(rabbitmq_senders) > 0)
|
|
83
|
+
has_senders = bool(rabbitmq_senders and len(rabbitmq_senders) > 0)
|
|
86
84
|
|
|
87
|
-
# 执行MQ异步初始化,传递是否有监听器的标志
|
|
88
85
|
try:
|
|
89
86
|
await instance._setup_mq_async(
|
|
90
87
|
rabbitmq_listeners=rabbitmq_listeners,
|
|
@@ -93,22 +90,26 @@ class Services(metaclass=SingletonMeta):
|
|
|
93
90
|
has_senders=has_senders
|
|
94
91
|
)
|
|
95
92
|
cls._initialized = True
|
|
96
|
-
logging.info("
|
|
93
|
+
logging.info("Services初始化完成")
|
|
97
94
|
except Exception as e:
|
|
98
|
-
logging.error(f"
|
|
95
|
+
logging.error(f"Services初始化失败: {str(e)}", exc_info=True)
|
|
99
96
|
raise
|
|
100
97
|
|
|
101
|
-
# 将实例挂载到app上
|
|
102
98
|
app.state.services = instance
|
|
103
99
|
|
|
104
|
-
|
|
100
|
+
# 2. 执行用户定义的生命周期
|
|
101
|
+
if cls._user_lifespan:
|
|
102
|
+
async with cls._user_lifespan(app):
|
|
103
|
+
yield # 应用运行阶段
|
|
104
|
+
else:
|
|
105
|
+
yield # 没有用户生命周期时直接 yield
|
|
105
106
|
|
|
106
|
-
#
|
|
107
|
+
# 3. 执行Services的关闭逻辑
|
|
107
108
|
await cls.shutdown()
|
|
108
|
-
logging.info("
|
|
109
|
+
logging.info("Services已关闭")
|
|
109
110
|
|
|
110
|
-
#
|
|
111
|
-
app.router.lifespan_context =
|
|
111
|
+
# 设置组合生命周期
|
|
112
|
+
app.router.lifespan_context = combined_lifespan
|
|
112
113
|
|
|
113
114
|
return app
|
|
114
115
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/DatabaseConfig.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/EmbeddingConfig.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/config/RerankerConfig.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/database/base_db_service.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/database/database_service.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/health/health_check.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/logging/logger_wrapper.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/__init__.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/exception.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/middleware.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/monitor_memory.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/timeout.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/middleware/traceid.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/mqlistener_config.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/mqmsg_model.py
RENAMED
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/models/mqsend_config.py
RENAMED
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/rabbitmq/rabbitmq_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sycommon_python_lib-0.1.15 → sycommon_python_lib-0.1.16}/src/sycommon/synacos/nacos_service.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
|