forked from p15670423/monkey
Island: Extract event topic to a variable in all Island event handler subscribe functions
This commit is contained in:
parent
5a96d5b570
commit
1f96ab5ea9
|
@ -28,25 +28,23 @@ def setup_island_event_handlers(container: DIContainer):
|
|||
def _subscribe_reset_agent_configuration_events(
|
||||
island_event_queue: IIslandEventQueue, container: DIContainer
|
||||
):
|
||||
island_event_queue.subscribe(
|
||||
IslandEventTopic.RESET_AGENT_CONFIGURATION, container.resolve(reset_agent_configuration)
|
||||
)
|
||||
topic = IslandEventTopic.RESET_AGENT_CONFIGURATION
|
||||
|
||||
island_event_queue.subscribe(topic, container.resolve(reset_agent_configuration))
|
||||
|
||||
|
||||
def _subscribe_clear_simulation_data_events(
|
||||
island_event_queue: IIslandEventQueue, container: DIContainer
|
||||
):
|
||||
topic = IslandEventTopic.CLEAR_SIMULATION_DATA
|
||||
|
||||
legacy_database_reset = partial(Database.reset_db, reset_config=False)
|
||||
island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, legacy_database_reset)
|
||||
island_event_queue.subscribe(topic, legacy_database_reset)
|
||||
|
||||
credentials_repository = container.resolve(ICredentialsRepository)
|
||||
island_event_queue.subscribe(
|
||||
IslandEventTopic.CLEAR_SIMULATION_DATA, credentials_repository.remove_stolen_credentials
|
||||
)
|
||||
island_event_queue.subscribe(topic, credentials_repository.remove_stolen_credentials)
|
||||
|
||||
island_event_queue.subscribe(
|
||||
IslandEventTopic.CLEAR_SIMULATION_DATA, container.resolve(reset_machine_repository)
|
||||
)
|
||||
island_event_queue.subscribe(topic, container.resolve(reset_machine_repository))
|
||||
|
||||
for i_repository in [
|
||||
INodeRepository,
|
||||
|
@ -54,15 +52,14 @@ def _subscribe_clear_simulation_data_events(
|
|||
IAgentRepository,
|
||||
]:
|
||||
repository = container.resolve(i_repository)
|
||||
island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, repository.reset)
|
||||
island_event_queue.subscribe(topic, repository.reset)
|
||||
|
||||
|
||||
def _subscribe_set_island_mode_events(
|
||||
island_event_queue: IIslandEventQueue, container: DIContainer
|
||||
):
|
||||
island_event_queue.subscribe(
|
||||
IslandEventTopic.SET_ISLAND_MODE, container.resolve(set_agent_configuration_per_island_mode)
|
||||
)
|
||||
island_event_queue.subscribe(
|
||||
IslandEventTopic.SET_ISLAND_MODE, container.resolve(set_simulation_mode)
|
||||
)
|
||||
topic = IslandEventTopic.SET_ISLAND_MODE
|
||||
|
||||
island_event_queue.subscribe(topic, container.resolve(set_agent_configuration_per_island_mode))
|
||||
|
||||
island_event_queue.subscribe(topic, container.resolve(set_simulation_mode))
|
||||
|
|
Loading…
Reference in New Issue