Improve names in EventHandlerFactoryBase to improve readability

This commit is contained in:
Kristóf Tóth 2019-07-23 11:47:59 +02:00
parent 9725f805ed
commit ae69a094c7

View File

@ -4,15 +4,15 @@ from .event_handler import EventHandler
class EventHandlerFactoryBase:
def build(self, event_handler, *, keys=None, event_handler_type=EventHandler):
builder = EventHandlerBuilder(event_handler, keys, event_handler_type)
def build(self, handler_stub, *, keys=None, event_handler_type=EventHandler):
builder = EventHandlerBuilder(handler_stub, keys, event_handler_type)
server_connector = self._build_server_connector()
real_event_handler = builder.build(server_connector)
event_handler.server_connector = server_connector
event_handler = builder.build(server_connector)
handler_stub.server_connector = server_connector
with suppress(AttributeError):
handler_stub.start()
event_handler.start()
real_event_handler.start()
return real_event_handler
return event_handler
def _build_server_connector(self):
raise NotImplementedError()
@ -20,7 +20,7 @@ class EventHandlerFactoryBase:
class EventHandlerBuilder:
def __init__(self, event_handler, supplied_keys, event_handler_type):
self._analyzer = EventHandlerAnalyzer(event_handler, supplied_keys)
self._analyzer = HandlerStubAnalyzer(event_handler, supplied_keys)
self._event_handler_type = event_handler_type
def build(self, server_connector):
@ -40,7 +40,7 @@ class EventHandlerBuilder:
raise
class EventHandlerAnalyzer:
class HandlerStubAnalyzer:
def __init__(self, event_handler, supplied_keys):
self._event_handler = event_handler
self._supplied_keys = supplied_keys