From 35e5b595d137f7bbed4f04f5f739bf3ec7624d90 Mon Sep 17 00:00:00 2001 From: "R. Richard" Date: Thu, 8 Aug 2019 14:45:59 +0200 Subject: [PATCH] Rename message keys --- tfw/components/fsm/fsm_handler.py | 6 +++--- tfw/components/fsm/fsm_updater.py | 2 +- tfw/components/process_management/log_inotify_observer.py | 2 +- tfw/components/process_management/process_log_handler.py | 4 ++-- tfw/internals/event_handling/fsm_aware.py | 8 ++------ 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tfw/components/fsm/fsm_handler.py b/tfw/components/fsm/fsm_handler.py index c9cb6eb..5d28c1f 100644 --- a/tfw/components/fsm/fsm_handler.py +++ b/tfw/components/fsm/fsm_handler.py @@ -9,7 +9,7 @@ LOG = logging.getLogger(__name__) class FSMHandler: - keys = ['fsm.step', 'fsm.update'] + keys = ['fsm.step', 'fsm.announce'] def __init__(self, *, fsm_type): self.fsm = fsm_type() self._fsm_updater = FSMUpdater(self.fsm) @@ -17,7 +17,7 @@ class FSMHandler: self.command_handlers = { 'fsm.step' : self.handle_step, - 'fsm.update' : self.handle_update + 'fsm.announce' : self.handle_announce } def handle_event(self, message, connector): @@ -34,6 +34,6 @@ class FSMHandler: if self.fsm.step(message['trigger']): return message - def handle_update(self, message): + def handle_announce(self, message): # pylint: disable=no-self-use return message diff --git a/tfw/components/fsm/fsm_updater.py b/tfw/components/fsm/fsm_updater.py index d1b42ec..276b65d 100644 --- a/tfw/components/fsm/fsm_updater.py +++ b/tfw/components/fsm/fsm_updater.py @@ -5,7 +5,7 @@ class FSMUpdater: @property def fsm_update(self): return { - 'key': 'fsm.announce', + 'key': 'fsm.update', **self.fsm_update_data } diff --git a/tfw/components/process_management/log_inotify_observer.py b/tfw/components/process_management/log_inotify_observer.py index 4ea88cf..97b6767 100644 --- a/tfw/components/process_management/log_inotify_observer.py +++ b/tfw/components/process_management/log_inotify_observer.py @@ -36,7 +36,7 @@ class LogInotifyObserver(InotifyObserver, ProcessLogManager): def on_modified(self, event): self._connector.send_message({ - 'key': 'log.new', + 'key': 'process.log.new', 'stdout': self.read_stdout(self.process_name, tail=self.log_tail), 'stderr': self.read_stderr(self.process_name, tail=self.log_tail) }, Scope.BROADCAST) diff --git a/tfw/components/process_management/process_log_handler.py b/tfw/components/process_management/process_log_handler.py index b23874e..144b1be 100644 --- a/tfw/components/process_management/process_log_handler.py +++ b/tfw/components/process_management/process_log_handler.py @@ -6,7 +6,7 @@ LOG = logging.getLogger(__name__) class ProcessLogHandler: - keys = ['log.set'] + keys = ['process.log.set'] def __init__(self, *, process_name, supervisor_uri, log_tail=0): self.connector, self._monitor = None, None @@ -15,7 +15,7 @@ class ProcessLogHandler: self._initial_log_tail = log_tail self.command_handlers = { - 'log.set': self.handle_set + 'process.log.set': self.handle_set } def start(self): diff --git a/tfw/internals/event_handling/fsm_aware.py b/tfw/internals/event_handling/fsm_aware.py index b700dba..b888220 100644 --- a/tfw/internals/event_handling/fsm_aware.py +++ b/tfw/internals/event_handling/fsm_aware.py @@ -6,11 +6,7 @@ LOG = logging.getLogger(__name__) class FSMAware: - keys = ['fsm.announce'] - """ - Base class for stuff that has to be aware of the framework FSM. - This is done by processing 'fsm_update' messages. - """ + keys = ['fsm.update'] def __init__(self): self.fsm_state = None self.fsm_in_accepted_state = False @@ -18,7 +14,7 @@ class FSMAware: self._auth_key = KeyManager().auth_key def process_message(self, message): - if message['key'] == 'fsm.announce': + if message['key'] == 'fsm.update': if verify_message(self._auth_key, message): self._handle_fsm_update(message)