| David Reiss | 9f3296b | 2010-08-31 16:58:41 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python | 
 | 2 | import sys | 
 | 3 | import time | 
 | 4 | import zmq | 
 | 5 | import TZmqClient | 
 | 6 | import thrift.protocol.TBinaryProtocol | 
 | 7 | import storage.ttypes | 
 | 8 | import storage.Storage | 
 | 9 |  | 
 | 10 |  | 
 | 11 | def main(args): | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 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: | 
| Stefan Bolus | e59b73d | 2018-05-14 14:48:09 +0200 | [diff] [blame^] | 18 |             socktype = zmq.PUSH | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 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 Reiss | 9f3296b | 2010-08-31 16:58:41 +0000 | [diff] [blame] | 27 |     if incr: | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 28 |         client.incr(incr) | 
 | 29 |         time.sleep(0.05) | 
 | 30 |     else: | 
 | 31 |         value = client.get() | 
| cclauss | 4bd3682 | 2017-09-01 17:40:29 +0200 | [diff] [blame] | 32 |         print(value) | 
| David Reiss | 9f3296b | 2010-08-31 16:58:41 +0000 | [diff] [blame] | 33 |  | 
 | 34 |  | 
 | 35 | if __name__ == "__main__": | 
| Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 36 |     main(sys.argv) |