An event mapper program receives a stream of events based on the event key attribute. Specific handler classes are required to handle that event.
My requirement is that I want to be able to add new event handlers in the future, without restarting the event mapper program.
I am able to load the specific event handler classes dynamically.
def loadClass(self,module,file_name,class_name):
try:
worker_module = getattr(__import__(module+'.'+file_name),file_name)
return getattr(worker_module, class_name)
except Exception as e:
print e
return None
I need a mapping between the event key attribute and the specific module
,file_name
and class_name
I'm thinking of maintaining the mapping in a seperate file with this mapping infomation, and read that to map every event, but I'm hoping that there is a better way.