Example #1
0
#include "magneto.h"
#include "gen-cpp/PingPongTest.h"

namespace magneto {
LOGGER_IMPL(magneto_logger, "magneto")
}

bool end=false;

void Service(const magneto::ProtocolRead& protocol_read, void* args) {
  const magneto::ProtocolReadThrift& protocol_read_thrift = 
    SCAST<const magneto::ProtocolReadThrift&>(protocol_read);
  magneto::Magneto& service = *RCAST<magneto::Magneto*>(args);
  app::PingPongTest_PingPong_args ping;
  magneto::BufToThrift<app::PingPongTest_PingPong_args>(
      protocol_read_thrift.Data(), 
      protocol_read_thrift.Size(),
      ping);

  app::PingPongTest_PingPong_result pong;
  pong.__isset.success = true;
  pong.success.token = 2 * ping.ping.token;

  magneto::ProtocolWriteThrift::Params params(
      protocol_read_thrift.Fn(), 
      magneto::ProtocolWriteThrift::kReply, 
      protocol_read_thrift.SeqId() + 1);

  std::string out;
  magneto::ThriftToBuf<app::PingPongTest_PingPong_result>(pong, out);
  service.WriteBack(magneto::Buf(magneto::Slice(out.data(), out.size()), &params), 100);
Example #2
0
#include "../public.h"
#include "../conf.h"
#include "../data.h"
#include "../plsa.h"

namespace xforce {
LOGGER_IMPL(xforce_logger, "ml")
}

int main() {
    LOGGER_SYS_INIT("conf/log.conf")

    xforce::ml::Conf conf;
    if (!conf.Init()) {
        std::cout << "fail_init_conf" << std::endl;
        return 1;
    }

    xforce::ml::Data data;
    if (!data.Init(conf)) {
        std::cout << "fail_init_data" << std::endl;
        return 2;
    }

    xforce::ml::Plsa plsa(conf, data);
    plsa.Start();
    plsa.Stop();
    return 0;
}