blob: 1886d9cab35868dd3d7e805843c382181e6e95e4 [file] [log] [blame]
David Reiss9f3296b2010-08-31 16:58:41 +00001#!/usr/bin/env python
2import sys
3import time
4import zmq
5import TZmqClient
6import thrift.protocol.TBinaryProtocol
7import storage.ttypes
8import storage.Storage
9
10
11def main(args):
12 endpoint = "tcp://127.0.0.1:9090"
13 socktype = zmq.REQ
14 incr = 0
15 if len(args) > 1:
16 incr = int(args[1])
17 if incr:
18 socktype = zmq.DOWNSTREAM
19 endpoint = "tcp://127.0.0.1:9091"
20
21 ctx = zmq.Context()
22 transport = TZmqClient.TZmqClient(ctx, endpoint, socktype)
23 protocol = thrift.protocol.TBinaryProtocol.TBinaryProtocolAccelerated(transport)
24 client = storage.Storage.Client(protocol)
25 transport.open()
26
27 if incr:
28 client.incr(incr)
29 time.sleep(0.05)
30 else:
31 value = client.get()
32 print value
33
34
35if __name__ == "__main__":
36 main(sys.argv)