mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-23 01:41:31 +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
|
if self._paused: return
|
||||||
log.debug(event)
|
log.debug(event)
|
||||||
key = 'webide'
|
key = 'webide'
|
||||||
self.uplink.send(key, {'key': key,
|
self.uplink.send(key, {'data': {'command': 'reload'}})
|
||||||
'data': {'command': 'reload'}})
|
|
||||||
|
|
||||||
|
|
||||||
class DirectoryMonitor:
|
class DirectoryMonitor:
|
||||||
|
@ -25,5 +25,4 @@ class ProcessManagingEventHandler(TriggerlessEventHandler):
|
|||||||
def handle_event(self, key, data_json):
|
def handle_event(self, key, data_json):
|
||||||
data = data_json['data']
|
data = data_json['data']
|
||||||
self.processmanager(data['command'], data['process_name'])
|
self.processmanager(data['command'], data['process_name'])
|
||||||
self.uplink.send(self.key, {'key': self.key,
|
self.uplink.send(self.key, {'data': {'process_name': data['process_name']}})
|
||||||
'data': {'process_name': data['process_name']}})
|
|
||||||
|
@ -14,8 +14,5 @@ class MessageSender:
|
|||||||
'timestamp': datetime.now().isoformat(),
|
'timestamp': datetime.now().isoformat(),
|
||||||
'message': message
|
'message': message
|
||||||
}
|
}
|
||||||
response = {
|
response = {'data': data}
|
||||||
'key': self.key,
|
|
||||||
'data': data
|
|
||||||
}
|
|
||||||
self.server_connector.send(self.key, response)
|
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))
|
self._zmq_push_socket.connect('tcp://localhost:{}'.format(tfwenv.RECEIVER_PORT))
|
||||||
|
|
||||||
def send(self, key, response):
|
def send(self, key, response):
|
||||||
|
response['key'] = key
|
||||||
self._zmq_push_socket.send_multipart(serialize_all(key, response))
|
self._zmq_push_socket.send_multipart(serialize_all(key, response))
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ class FSMUpdater:
|
|||||||
|
|
||||||
def generate_fsm_update(self):
|
def generate_fsm_update(self):
|
||||||
key = 'FSMUpdate'
|
key = 'FSMUpdate'
|
||||||
response = {'key': key,
|
response = {'data': {'current_state': self.fsm.state,
|
||||||
'data': {'current_state': self.fsm.state,
|
|
||||||
'valid_transitions':
|
'valid_transitions':
|
||||||
[{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]}}
|
[{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]}}
|
||||||
return key, response
|
return key, response
|
||||||
|
Loading…
Reference in New Issue
Block a user