I’m somewhat new to Python and Nameko, but I was wondering if it was possible to create event handlers dynamically. For example, I would want new services to be able to register with an existing service. That existing service would listen for new service events.
class ExistingService:
name = "existingservice"
@rpc
def register_new_service(self, service_name, event_type):
# How can I create a new event handler on ExistingService that will listen for service_name/event_type dynamically?
class NewService:
name = "newservice"
event_type = "newservice_event"
service_rpc = RpcProxy('existingservice')
def __init__(self):
self.register_myself()
def register_myself(self):
self.service_rpc.register_new_service(self.name, self.event_type)