From 141c766b51d8faa55b8bd66582958ff34d521091 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 17 Aug 2022 21:29:06 +0530 Subject: [PATCH] Common: Add EventSerializerRegistry --- .../event_serializer_registry.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 monkey/common/event_serializers/event_serializer_registry.py diff --git a/monkey/common/event_serializers/event_serializer_registry.py b/monkey/common/event_serializers/event_serializer_registry.py new file mode 100644 index 000000000..2b49f4223 --- /dev/null +++ b/monkey/common/event_serializers/event_serializer_registry.py @@ -0,0 +1,17 @@ +from common.event_serializers import IEventSerializer + + +class EventSerializerRegistry: + """ + Registry for event serializers + """ + + def __init__(self): + self._registry = {} + + def __setitem__(self, event_class_name: str, event_serializer: IEventSerializer): + self._registry[event_class_name] = event_serializer + + def __getitem__(self, event_class_name: str): + event_serializer = self._registry[event_class_name] + return event_serializer