blob: 5767b71fe82edc3dfce4bef316a229a1c99a3320 [file] [log] [blame]
David Reiss9f3296b2010-08-31 16:58:41 +00001#!/usr/bin/env python
2import zmq
3import TZmqServer
4import storage.ttypes
5import storage.Storage
6
7
8class StorageHandler(storage.Storage.Iface):
9 def __init__(self):
10 self.value = 0
11
12 def incr(self, amount):
13 self.value += amount
14
15 def get(self):
16 return self.value
17
18
19def main():
20 handler = StorageHandler()
21 processor = storage.Storage.Processor(handler)
22
23 ctx = zmq.Context()
24 reqrep_server = TZmqServer.TZmqServer(processor, ctx, "tcp://0.0.0.0:9090", zmq.REP)
25 oneway_server = TZmqServer.TZmqServer(processor, ctx, "tcp://0.0.0.0:9091", zmq.UPSTREAM)
26 multiserver = TZmqServer.TZmqMultiServer()
27 multiserver.servers.append(reqrep_server)
28 multiserver.servers.append(oneway_server)
29 multiserver.serveForever()
30
31
32if __name__ == "__main__":
33 main()