blob: 4ea4a9b8c0473565db246a73c33d7e13f50ca1e9 [file] [log] [blame]
David Reiss5ddabb82010-10-06 17:09:37 +00001#!/usr/bin/env python
2import sys
3import time
4from thrift.transport import TTransport
5from thrift.transport import TSocket
6from thrift.protocol import TBinaryProtocol
7from thrift.server import THttpServer
8from aggr import Aggr
9
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090010
David Reiss5ddabb82010-10-06 17:09:37 +000011class AggrHandler(Aggr.Iface):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090012 def __init__(self):
13 self.values = []
David Reiss5ddabb82010-10-06 17:09:37 +000014
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090015 def addValue(self, value):
16 self.values.append(value)
David Reiss5ddabb82010-10-06 17:09:37 +000017
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090018 def getValues(self, ):
19 time.sleep(1)
20 return self.values
David Reiss5ddabb82010-10-06 17:09:37 +000021
22processor = Aggr.Processor(AggrHandler())
23pfactory = TBinaryProtocol.TBinaryProtocolFactory()
24THttpServer.THttpServer(processor, ('', int(sys.argv[1])), pfactory).serve()