|
85 | 85 | get_local_dbos_context, |
86 | 86 | ) |
87 | 87 | from ._dbos_config import ConfigFile, load_config, set_env_vars |
88 | | -from ._error import DBOSException, DBOSNonExistentWorkflowError |
| 88 | +from ._error import ( |
| 89 | + DBOSConflictingRegistrationError, |
| 90 | + DBOSException, |
| 91 | + DBOSNonExistentWorkflowError, |
| 92 | +) |
89 | 93 | from ._logger import add_otlp_to_all_loggers, dbos_logger |
90 | 94 | from ._sys_db import SystemDatabase |
91 | 95 |
|
@@ -144,14 +148,19 @@ def _get_or_create_dbos_registry() -> DBOSRegistry: |
144 | 148 | class DBOSRegistry: |
145 | 149 | def __init__(self) -> None: |
146 | 150 | self.workflow_info_map: dict[str, Workflow[..., Any]] = {} |
| 151 | + self.function_type_map: dict[str, str] = {} |
147 | 152 | self.class_info_map: dict[str, type] = {} |
148 | 153 | self.instance_info_map: dict[str, object] = {} |
149 | 154 | self.queue_info_map: dict[str, Queue] = {} |
150 | 155 | self.pollers: list[RegisteredJob] = [] |
151 | 156 | self.dbos: Optional[DBOS] = None |
152 | 157 | self.config: Optional[ConfigFile] = None |
153 | 158 |
|
154 | | - def register_wf_function(self, name: str, wrapped_func: F) -> None: |
| 159 | + def register_wf_function(self, name: str, wrapped_func: F, functype: str) -> None: |
| 160 | + if name in self.function_type_map: |
| 161 | + if self.function_type_map[name] != functype: |
| 162 | + raise DBOSConflictingRegistrationError(name) |
| 163 | + self.function_type_map[name] = functype |
155 | 164 | self.workflow_info_map[name] = wrapped_func |
156 | 165 |
|
157 | 166 | def register_class(self, cls: type, ci: DBOSClassInfo) -> None: |
@@ -324,7 +333,7 @@ def send_temp_workflow( |
324 | 333 | temp_send_wf = workflow_wrapper(self._registry, send_temp_workflow) |
325 | 334 | set_dbos_func_name(send_temp_workflow, TEMP_SEND_WF_NAME) |
326 | 335 | set_temp_workflow_type(send_temp_workflow, "send") |
327 | | - self._registry.register_wf_function(TEMP_SEND_WF_NAME, temp_send_wf) |
| 336 | + self._registry.register_wf_function(TEMP_SEND_WF_NAME, temp_send_wf, "send") |
328 | 337 |
|
329 | 338 | for handler in dbos_logger.handlers: |
330 | 339 | handler.flush() |
|
0 commit comments