17 #include <gflags/gflags.h> 31 using namespace folly;
34 using thrift::test::Bonk;
35 using thrift::test::Xtruct;
45 std::shared_ptr<AsyncTransportWrapper> sock)
override {
64 auto search = requests_.find(in.i32_thing);
65 CHECK(search != requests_.end());
67 requests_.erase(in.i32_thing);
72 auto& p = requests_[arg.type];
73 auto f = p.getFuture();
75 this->requests_.erase(arg.type);
77 this->pipeline_->write(arg);
85 printf(
"Channel closed\n");
90 printf(
"Channel closed\n");
95 std::unordered_map<int32_t, Promise<Xtruct>>
requests_;
108 client.
group(std::make_shared<folly::IOThreadPoolExecutor>(1));
117 auto dispatcher = std::make_shared<BonkMultiplexClientDispatcher>();
118 dispatcher->setPipeline(pipeline);
125 std::cout <<
"Input string and int" << std::endl;
128 std::cin >> request.message;
129 std::cin >> request.type;
130 service(request).thenValue([request](Xtruct response) {
131 CHECK(request.type == response.i32_thing);
132 std::cout << response.string_thing << std::endl;
135 }
catch (
const std::exception& e) {
Future< Xtruct > operator()(Bonk arg) override
Future< Unit > close() override
fbstring exceptionStr(const std::exception &e)
constexpr detail::Map< Move > move
folly::Future< Pipeline * > connect(const folly::SocketAddress &address, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) override
—— Concurrent Priority Queue Implementation ——
DEFINE_string(host,"::1","test server address")
void init(int *argc, char ***argv, bool removeFlags)
BaseClientBootstrap< Pipeline > * pipelineFactory(std::shared_ptr< PipelineFactory< Pipeline >> factory) noexcept
int main(int argc, char **argv)
Future< Unit > close(Context *ctx) override
DEFINE_int32(port, 8080,"test server port")
std::unordered_map< int32_t, Promise< Xtruct > > requests_
std::shared_ptr< Pipeline > Ptr
SerializePipeline::Ptr newPipeline(std::shared_ptr< AsyncTransportWrapper > sock) override
ClientBootstrap * group(std::shared_ptr< folly::IOThreadPoolExecutor > group)
int close(NetworkSocket s)
void read(Context *, Xtruct in) override