Skip to content

Commit ccf4670

Browse files
committed
Add send_manager collector
1 parent 295a465 commit ccf4670

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pathlib
2+
import typing
3+
4+
import chalicelib.send_manager.__interface__ as send_mgr_interface
5+
import chalicelib.util.import_util as import_util
6+
7+
_SendManagerCollectionType = dict[str, send_mgr_interface.SendManagerInterface]
8+
send_managers: _SendManagerCollectionType = {}
9+
10+
for _path in pathlib.Path(__file__).parent.glob("*.py"):
11+
if _path.stem.startswith("__") or not (
12+
_patterns := typing.cast(
13+
_SendManagerCollectionType,
14+
getattr(import_util.load_module(_path), "send_manager_patterns", None),
15+
)
16+
):
17+
continue
18+
19+
if _duplicated := send_managers.keys() & _patterns.keys():
20+
raise ValueError(f"Send manager {_duplicated} is already registered")
21+
22+
send_managers.update(_patterns)

0 commit comments

Comments
 (0)