进一步清理代码和注册过程
This commit is contained in:
@@ -17,7 +17,7 @@ Domain 注册中心
|
||||
node_type="contract",
|
||||
schema=ContractResponse,
|
||||
node_class=ContractSyncNode,
|
||||
jsonl_handler_class=ContractJsonlHandler
|
||||
jsonl_handler_class=ContractJsonlHandler,
|
||||
)
|
||||
|
||||
# Collection 查询 SyncNode 类
|
||||
@@ -47,7 +47,6 @@ class DomainRegistration:
|
||||
strategy_class: Optional[Type[Any]] = None # 可选,部分 domain 可能只读
|
||||
jsonl_handler_class: Optional[Type[Any]] = None
|
||||
api_handler_class: Optional[Type[Any]] = None
|
||||
db_handler_class: Optional[Type[Any]] = None
|
||||
handler_classes: Dict[str, Type[Any]] = field(default_factory=dict)
|
||||
metadata: Dict[str, Any] = field(default_factory=dict) # 额外元数据
|
||||
|
||||
@@ -69,7 +68,6 @@ class DomainRegistry:
|
||||
_BUILTIN_HANDLER_ATTRS: Dict[str, str] = {
|
||||
"jsonl": "jsonl_handler_class",
|
||||
"api": "api_handler_class",
|
||||
"db": "db_handler_class",
|
||||
}
|
||||
|
||||
@classmethod
|
||||
@@ -81,7 +79,6 @@ class DomainRegistry:
|
||||
strategy_class: Optional[Type[Any]] = None,
|
||||
jsonl_handler_class: Optional[Type[Any]] = None,
|
||||
api_handler_class: Optional[Type[Any]] = None,
|
||||
db_handler_class: Optional[Type[Any]] = None,
|
||||
**metadata
|
||||
) -> None:
|
||||
"""
|
||||
@@ -94,7 +91,6 @@ class DomainRegistry:
|
||||
strategy_class: Strategy 子类(可选)
|
||||
jsonl_handler_class: JSONL Handler 类(可选)
|
||||
api_handler_class: API Handler 类(可选)
|
||||
db_handler_class: DB Handler 类(可选)
|
||||
**metadata: 额外的元数据
|
||||
|
||||
Raises:
|
||||
@@ -110,7 +106,6 @@ class DomainRegistry:
|
||||
strategy_class=strategy_class,
|
||||
jsonl_handler_class=jsonl_handler_class,
|
||||
api_handler_class=api_handler_class,
|
||||
db_handler_class=db_handler_class,
|
||||
metadata=metadata
|
||||
)
|
||||
for datasource_type, attr_name in cls._BUILTIN_HANDLER_ATTRS.items():
|
||||
@@ -187,10 +182,6 @@ class DomainRegistry:
|
||||
setattr(reg, attr_name, handler_class)
|
||||
|
||||
@classmethod
|
||||
def register_db_handler(cls, node_type: str, db_handler_class: Type[Any]) -> None:
|
||||
"""为已注册 domain 补充 DB Handler。"""
|
||||
cls.register_handler(node_type, "db", db_handler_class)
|
||||
|
||||
@classmethod
|
||||
def get_schema(cls, node_type: str) -> Type[BaseModel]:
|
||||
"""获取 Schema 类"""
|
||||
@@ -245,7 +236,6 @@ class DomainRegistry:
|
||||
print(f" Strategy Class: {reg.strategy_class.__name__ if reg.strategy_class else '❌ None'}")
|
||||
print(f" JSONL Handler: {reg.jsonl_handler_class.__name__ if reg.jsonl_handler_class else '❌ None'}")
|
||||
print(f" API Handler: {reg.api_handler_class.__name__ if reg.api_handler_class else '❌ None'}")
|
||||
print(f" DB Handler: {reg.db_handler_class.__name__ if reg.db_handler_class else '❌ None'}")
|
||||
extra_handler_types = sorted(
|
||||
handler_type for handler_type in reg.handler_classes if handler_type not in cls._BUILTIN_HANDLER_ATTRS
|
||||
)
|
||||
@@ -272,7 +262,7 @@ class DomainRegistry:
|
||||
"has_strategy": True,
|
||||
"has_jsonl_handler": True,
|
||||
"has_api_handler": True,
|
||||
"has_db_handler": False
|
||||
"handler_types": []
|
||||
},
|
||||
...
|
||||
}
|
||||
@@ -284,7 +274,6 @@ class DomainRegistry:
|
||||
"has_strategy": reg.strategy_class is not None,
|
||||
"has_jsonl_handler": reg.jsonl_handler_class is not None,
|
||||
"has_api_handler": reg.api_handler_class is not None,
|
||||
"has_db_handler": reg.db_handler_class is not None,
|
||||
"handler_types": sorted(reg.handler_classes.keys()),
|
||||
}
|
||||
return summary
|
||||
|
||||
Reference in New Issue
Block a user