blob: 55c23e0a0fd64ce9968c4ebcf63cf10068f31f1e [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):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090012 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
David Reiss9f3296b2010-08-31 16:58:41 +000027 if incr:
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090028 client.incr(incr)
29 time.sleep(0.05)
30 else:
31 value = client.get()
cclauss4bd36822017-09-01 17:40:29 +020032 print(value)
David Reiss9f3296b2010-08-31 16:58:41 +000033
34
35if __name__ == "__main__":
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090036 main(sys.argv)