Common: Add EventSerializerRegistry

This commit is contained in:
Shreya Malviya 2022-08-17 21:29:06 +05:30
parent 0b9191ca43
commit 141c766b51
1 changed files with 17 additions and 0 deletions

View File

@ -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