blob: d2fc56ce137b23e28d10e6e53eb74ea4eb25dc2d [file] [log] [blame]
David Reiss9f3296b2010-08-31 16:58:41 +00001#include <iostream>
2#include <cstdlib>
Roger Meier49ff8b12012-04-13 09:12:31 +00003#include <thrift/protocol/TBinaryProtocol.h>
David Reiss9f3296b2010-08-31 16:58:41 +00004
5#include "zmq.hpp"
6#include "TZmqClient.h"
7#include "Storage.h"
8
9using boost::shared_ptr;
10using apache::thrift::transport::TZmqClient;
11using apache::thrift::protocol::TBinaryProtocol;
12
13int main(int argc, char** argv) {
14 const char* endpoint = "tcp://127.0.0.1:9090";
15 int socktype = ZMQ_REQ;
16 int incr = 0;
17 if (argc > 1) {
18 incr = atoi(argv[1]);
19 if (incr) {
20 socktype = ZMQ_DOWNSTREAM;
21 endpoint = "tcp://127.0.0.1:9091";
22 }
23 }
24
25 zmq::context_t ctx(1);
26 shared_ptr<TZmqClient> transport(new TZmqClient(ctx, endpoint, socktype));
27 shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
28 StorageClient client(protocol);
29 transport->open();
30
31 if (incr) {
32 client.incr(incr);
33 usleep(50000);
34 } else {
35 int value = client.get();
36 std::cout << value << std::endl;
37 }
38
39 return 0;
40}