def response_hook(self, input, instance, attrs, service_type): if service_type == 'get_list': # Details are needed when topics are in their own main screen but if only basic information # is needed, like a list of topic IDs and names, we don't need to look up additional details. # The latter is the case of the message publication screen which simply needs a list of topic IDs/names. if input.get('needs_details', True): with closing(self.odb.session()) as session: for item in self.response.payload: # Checks current non-GD depth on all servers item.current_depth_non_gd = self.invoke( 'zato.pubsub.topic.collect-non-gd-depth', { 'topic_name': item.name, })['response']['current_depth_non_gd'] # Checks current GD depth in SQL item.current_depth_gd = get_gd_depth_topic( session, input.cluster_id, item.id) last_data = get_last_pub_data(self.kvdb.conn, self.server.cluster_id, item.id) if last_data: item.last_pub_time = last_data['pub_time'] item.last_pub_has_gd = last_data['has_gd'] item.last_pub_msg_id = last_data['pub_msg_id'] item.last_endpoint_id = last_data['endpoint_id'] item.last_endpoint_name = last_data['endpoint_name'] item.last_pub_server_pid = last_data.get('server_pid') item.last_pub_server_name = last_data.get( 'server_name')
def handle(self): with closing(self.odb.session()) as session: topic = pubsub_topic(session, self.request.input.cluster_id, self.request.input.id) topic['current_depth_gd'] = get_gd_depth_topic(session, self.request.input.cluster_id, self.request.input.id) last_data = get_last_pub_data(self.kvdb.conn, self.server.cluster_id, self.request.input.id) if last_data: topic['last_pub_time'] = last_data['pub_time'] self.response.payload = topic