def stringReceived(self, rawRequest): request = pickle.loads(rawRequest) log.query("%s" % request) datapoints = MetricCache.get(request['metric']) rs = dict(datapoints=datapoints) response = pickle.dumps(rs, protocol=-1) self.sendString(response)
def connectionLost(self, reason): if reason.check(ConnectionDone): log.query("%s disconnected" % self.peerAddr) else: log.query("%s connection lost: %s" % (self.peerAddr, reason.value))
def connectionMade(self): peer = self.transport.getPeer() self.peerAddr = "%s:%s" % (peer.host, peer.port) log.query("%s connected" % self.peerAddr)