gorealis/vendor/git.apache.org/thrift.git/contrib/zeromq/test-client.cpp
Renan DelValle 8d445c1c77
Moving from govendor to dep, updated dependencies (#48)
* Moving from govendor to dep.

* Making the pull request template more friendly.

* Fixing akward space in PR template.

* goimports run on whole project using ` goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./gen-go/*")`

source of command: https://gist.github.com/bgentry/fd1ffef7dbde01857f66
2018-01-07 13:13:47 -08:00

40 lines
923 B
C++

#include <iostream>
#include <cstdlib>
#include <thrift/protocol/TBinaryProtocol.h>
#include "zmq.hpp"
#include "TZmqClient.h"
#include "Storage.h"
using boost::shared_ptr;
using apache::thrift::transport::TZmqClient;
using apache::thrift::protocol::TBinaryProtocol;
int main(int argc, char** argv) {
const char* endpoint = "tcp://127.0.0.1:9090";
int socktype = ZMQ_REQ;
int incr = 0;
if (argc > 1) {
incr = atoi(argv[1]);
if (incr) {
socktype = ZMQ_DOWNSTREAM;
endpoint = "tcp://127.0.0.1:9091";
}
}
zmq::context_t ctx(1);
shared_ptr<TZmqClient> transport(new TZmqClient(ctx, endpoint, socktype));
shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
StorageClient client(protocol);
transport->open();
if (incr) {
client.incr(incr);
usleep(50000);
} else {
int value = client.get();
std::cout << value << std::endl;
}
return 0;
}