Commit e71f2950 by Amir Aharon

first testing of Evpp

parent 35304c19
...@@ -120,14 +120,24 @@ void Microservice_IRestServerEvppImpl::stop(){ ...@@ -120,14 +120,24 @@ void Microservice_IRestServerEvppImpl::stop(){
bool Microservice_IRestServerEvppImpl::init(){ bool Microservice_IRestServerEvppImpl::init(){
p_server_ = new evpp::http::Server(p_param_->getWorkerThreadsNum()); p_server_ = new evpp::http::Server(p_param_->getWorkerThreadsNum());
p_server_->SetThreadDispatchPolicy(evpp::ThreadDispatchPolicy::kIPAddressHashing); p_server_->SetThreadDispatchPolicy(evpp::ThreadDispatchPolicy::kIPAddressHashing);
p_server_->RegisterDefaultHandler(&DefaultHandler); p_server_->RegisterDefaultHandler([this](evpp::EventLoop* loop,
p_server_->RegisterHandler("/",
[this](evpp::EventLoop* loop,
const evpp::http::ContextPtr& ctx, const evpp::http::ContextPtr& ctx,
const evpp::http::HTTPSendResponseCallback& cb) { const evpp::http::HTTPSendResponseCallback& cb) {
EvppConnParams connParams(ctx,cb); EvppConnParams connParams(ctx,cb);
this->HandleRequest(connParams); this->HandleRequest(connParams);
}); });
// p_server_->RegisterHandler("/test",
// [this](evpp::EventLoop* loop,
// const evpp::http::ContextPtr& ctx,
// const evpp::http::HTTPSendResponseCallback& cb) {
// std::stringstream oss;
// oss << "testing 1..2..3.." << "\n";
// ctx->set_response_http_code(200);
// ctx->AddResponseHeader(nsMicroservice_Constants::STD_STRING_HEADER_CONTENT_TYPE,
// nsMicroservice_Constants::STD_STRING_CONTENT_TYPE_TEXT);
// ctx->AddResponseHeader("Server", "ipgms");
// cb(oss.str());
// });
p_server_->Init(p_param_->getPort()); p_server_->Init(p_param_->getPort());
return true; return true;
......
...@@ -104,7 +104,6 @@ private: ...@@ -104,7 +104,6 @@ private:
class Microservice_IRestServerEvppImpl : public nsMicroservice_Iface::IRestServer , public nsMicroservice_Iface::IContainer { class Microservice_IRestServerEvppImpl : public nsMicroservice_Iface::IRestServer , public nsMicroservice_Iface::IContainer {
public: public:
Microservice_IRestServerEvppImpl(cMicroservice_RestServerParams* p_param); Microservice_IRestServerEvppImpl(cMicroservice_RestServerParams* p_param);
Microservice_IRestServerEvppImpl(const Microservice_IRestServerEvppImpl& orig) {} Microservice_IRestServerEvppImpl(const Microservice_IRestServerEvppImpl& orig) {}
......
...@@ -7,12 +7,18 @@ ...@@ -7,12 +7,18 @@
#include <impl/servers/Microservice_IMsgQueueServerZmqImpl.h> #include <impl/servers/Microservice_IMsgQueueServerZmqImpl.h>
//#include <impl/servers/Microservice_IRestServerRMQImpl.h> //#include <impl/servers/Microservice_IRestServerRMQImpl.h>
#include <impl/servers/Microservice_IRestServerZmqImpl.h> #include <impl/servers/Microservice_IRestServerZmqImpl.h>
#include <impl/servers/Microservice_IRestServerEvppImpl.h>
cMicroservice_IRestServerCivetWebImpl * cMicroservice_IRestServerCivetWebImpl *
ServerFactory::createIRestServerCivetWebImpl(std::string host, int port, int workerThreadsNum) { ServerFactory::createIRestServerCivetWebImpl(std::string host, int port, int workerThreadsNum) {
return new cMicroservice_IRestServerCivetWebImpl(new cMicroservice_RestServerParams(port,host,workerThreadsNum)); return new cMicroservice_IRestServerCivetWebImpl(new cMicroservice_RestServerParams(port,host,workerThreadsNum));
} }
Microservice_IRestServerEvppImpl*
ServerFactory::createIRestServerEvppImpl(std::string host, int port, int workerThreadsNum){
return new Microservice_IRestServerEvppImpl(new cMicroservice_RestServerParams(port,host,workerThreadsNum));
}
Microservice_IMsgQueueServerZmqImpl * Microservice_IMsgQueueServerZmqImpl *
ServerFactory::createIMsgQueueServerZmqImpl(std::string host, int port, Microservice_ZMQServerParams::eProtocol protocol) { ServerFactory::createIMsgQueueServerZmqImpl(std::string host, int port, Microservice_ZMQServerParams::eProtocol protocol) {
return new Microservice_IMsgQueueServerZmqImpl(Microservice_ZMQServerParams(host,port,protocol)); return new Microservice_IMsgQueueServerZmqImpl(Microservice_ZMQServerParams(host,port,protocol));
......
...@@ -12,6 +12,7 @@ class cMicroservice_IRestServerCivetWebImpl; ...@@ -12,6 +12,7 @@ class cMicroservice_IRestServerCivetWebImpl;
class Microservice_IMsgQueueServerZmqImpl; class Microservice_IMsgQueueServerZmqImpl;
//class cMicroservice_IRestServerRMQImpl; //class cMicroservice_IRestServerRMQImpl;
class Microservice_IRestServerZmqImpl; class Microservice_IRestServerZmqImpl;
class Microservice_IRestServerEvppImpl;
/** /**
* factory to create different servers * factory to create different servers
...@@ -22,6 +23,10 @@ public: ...@@ -22,6 +23,10 @@ public:
static cMicroservice_IRestServerCivetWebImpl* createIRestServerCivetWebImpl(std::string host, static cMicroservice_IRestServerCivetWebImpl* createIRestServerCivetWebImpl(std::string host,
int port, int port,
int workerThreadsNum); int workerThreadsNum);
static Microservice_IRestServerEvppImpl* createIRestServerEvppImpl(std::string host,
int port,
int workerThreadsNum);
static Microservice_IMsgQueueServerZmqImpl* createIMsgQueueServerZmqImpl(std::string host, static Microservice_IMsgQueueServerZmqImpl* createIMsgQueueServerZmqImpl(std::string host,
int port, int port,
Microservice_ZMQServerParams::eProtocol aProtocol); Microservice_ZMQServerParams::eProtocol aProtocol);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <params/Microservice_Params.h> #include <params/Microservice_Params.h>
#include <document.h> //rapidjson #include <document.h> //rapidjson
#include <impl/servers/Microservice_IRestServerCivetWebImpl.h> #include <impl/servers/Microservice_IRestServerCivetWebImpl.h>
#include <impl/servers/Microservice_IRestServerEvppImpl.h>
#include <impl/servers/Microservice_IMsgQueueServerZmqImpl.h> #include <impl/servers/Microservice_IMsgQueueServerZmqImpl.h>
// #include <impl/servers/Microservice_IRestServerRMQImpl.h> // #include <impl/servers/Microservice_IRestServerRMQImpl.h>
#include <impl/Microservice_ICacheClientRedisImpl.h> #include <impl/Microservice_ICacheClientRedisImpl.h>
...@@ -382,7 +383,8 @@ int main(int argc, char *argv[]) ...@@ -382,7 +383,8 @@ int main(int argc, char *argv[])
.addClient(ClientFactory::createHttpImplMsClient("other-service", "localhost", 32010, true, 10, false,"localhost:6379")) //new cMicroservice_Client(new MSICommandClientHttpImpl(),&clientParams)) .addClient(ClientFactory::createHttpImplMsClient("other-service", "localhost", 32010, true, 10, false,"localhost:6379")) //new cMicroservice_Client(new MSICommandClientHttpImpl(),&clientParams))
.addClient(ClientFactory::createZmqMsgQImp("zmq-service", msApp.name(), 0, .addClient(ClientFactory::createZmqMsgQImp("zmq-service", msApp.name(), 0,
Microservice_ZMQServerParams::eProtocol::eIpc)) Microservice_ZMQServerParams::eProtocol::eIpc))
.addServer(ServerFactory::createIRestServerCivetWebImpl("", 50010, 1))// .addRestServer(new cMicroservice_IRestServerCivetWebImpl(new cMicroservice_RestServerParams(50010,"",1))) //.addServer(ServerFactory::createIRestServerCivetWebImpl("", 50010, 1))
.addServer(ServerFactory::createIRestServerEvppImpl("", 50010, 8))
.addServer(ServerFactory::createIMsgQueueServerZmqImpl(msApp.name(), 0, Microservice_ZMQServerParams::eProtocol::eIpc)) .addServer(ServerFactory::createIMsgQueueServerZmqImpl(msApp.name(), 0, Microservice_ZMQServerParams::eProtocol::eIpc))
.addHandler("/xxx",(Microservice_RestHandler*)new cMicroserviceHandler("hello")) .addHandler("/xxx",(Microservice_RestHandler*)new cMicroserviceHandler("hello"))
.addHandler("/zmq",new MSMsgQHandler()) .addHandler("/zmq",new MSMsgQHandler())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment