mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 21:51:32 +00:00
Refactor ServerUplinkConnector to avoid passing redundant data
This commit is contained in:
parent
9eaced9f02
commit
e29b300925
@ -25,8 +25,7 @@ class WebideReloadEventHandler(FileSystemEventHandler):
|
||||
if self._paused: return
|
||||
log.debug(event)
|
||||
key = 'webide'
|
||||
self.uplink.send(key, {'key': key,
|
||||
'data': {'command': 'reload'}})
|
||||
self.uplink.send(key, {'data': {'command': 'reload'}})
|
||||
|
||||
|
||||
class DirectoryMonitor:
|
||||
|
@ -25,5 +25,4 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
||||
def handle_event(self, key, data_json):
|
||||
data = data_json['data']
|
||||
self.processmanager(data['command'], data['process_name'])
|
||||
self.uplink.send(self.key, {'key': self.key,
|
||||
'data': {'process_name': data['process_name']}})
|
||||
self.uplink.send(self.key, {'data': {'process_name': data['process_name']}})
|
||||
|
@ -14,8 +14,5 @@ class MessageSender:
|
||||
'timestamp': datetime.now().isoformat(),
|
||||
'message': message
|
||||
}
|
||||
response = {
|
||||
'key': self.key,
|
||||
'data': data
|
||||
}
|
||||
response = {'data': data}
|
||||
self.server_connector.send(self.key, response)
|
||||
|
@ -26,6 +26,7 @@ class ServerUplinkConnector(ZMQConnectorBase):
|
||||
self._zmq_push_socket.connect('tcp://localhost:{}'.format(tfwenv.RECEIVER_PORT))
|
||||
|
||||
def send(self, key, response):
|
||||
response['key'] = key
|
||||
self._zmq_push_socket.send_multipart(serialize_all(key, response))
|
||||
|
||||
|
||||
|
@ -46,8 +46,7 @@ class FSMUpdater:
|
||||
|
||||
def generate_fsm_update(self):
|
||||
key = 'FSMUpdate'
|
||||
response = {'key': key,
|
||||
'data': {'current_state': self.fsm.state,
|
||||
response = {'data': {'current_state': self.fsm.state,
|
||||
'valid_transitions':
|
||||
[{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]}}
|
||||
return key, response
|
||||
|
Loading…
Reference in New Issue
Block a user