blob: c624b0d8dbb2da95453c8cdcff579720b917f942 [file] [log] [blame]
David Reiss9f3296b2010-08-31 16:58:41 +00001#include "zmq.hpp"
2#include "TZmqServer.h"
3#include "Storage.h"
4
5using boost::shared_ptr;
6using apache::thrift::TProcessor;
7using apache::thrift::server::TZmqServer;
8using apache::thrift::server::TZmqMultiServer;
9
10class StorageHandler : virtual public StorageIf {
11 public:
12 StorageHandler()
13 : value_(0)
14 {}
15
16 void incr(const int32_t amount) {
17 value_ += amount;
18 }
19
20 int32_t get() {
21 return value_;
22 }
23
24 private:
25 int32_t value_;
26
27};
28
29
30int main(int argc, char *argv[]) {
31 shared_ptr<StorageHandler> handler(new StorageHandler());
32 shared_ptr<TProcessor> processor(new StorageProcessor(handler));
33
34 zmq::context_t ctx(1);
35 TZmqServer reqrep_server(processor, ctx, "tcp://0.0.0.0:9090", ZMQ_REP);
36 TZmqServer oneway_server(processor, ctx, "tcp://0.0.0.0:9091", ZMQ_UPSTREAM);
37 TZmqMultiServer multiserver;
38 multiserver.servers().push_back(&reqrep_server);
39 multiserver.servers().push_back(&oneway_server);
40 multiserver.serveForever();
41
42 return 0;
43}