Commit e0cb4bb9 by amir

start working on feature

parent 7b356122
......@@ -18,7 +18,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set ( PROJECT_LINK_LIBS -ljson -lhiredis -lcpprest -lcppmetrics -lboost_random -lboost_timer -lboost_chrono
-lboost_system -lboost_thread -lboost_date_time -lboost_regex -lboost_filesystem -lpthread
-lboost_random -lboost_chrono -lboost_system -lboost_thread -lssl
-lcrypto -lRabbitmq -lrabbitmq -llog4cpp -lglog )
-lcrypto -lRabbitmq -lrabbitmq -llog4cpp -lglog -lczmq)
link_directories( ../3party/lib )
link_directories( ../internals/lib )
......@@ -31,12 +31,13 @@ include_directories(SYSTEM ../3party/cpprest/Release/include)
include_directories(SYSTEM ../3party/rabbitmq)
include_directories(SYSTEM ../internals/include/Rabbitmq)
include_directories(SYSTEM /usr/include/hiredis)
include_directories(SYSTEM ../3party/czmq-4.0.0/include)
# recursive search files cpp files
file(GLOB_RECURSE SOURCES "src/*.cpp")
set (3PARTY_SOURCES ../3party/mongoose/mongoose.c)
#Generate the shared library from the sources
add_library(Microservice SHARED ${SOURCES} ${3PARTY_SOURCES} src/common/Microservice_RestResponse.h)
add_library(Microservice SHARED ${SOURCES} ${3PARTY_SOURCES} src/common/Microservice_RestResponse.h src/impl/servers/Microservice_IMsgQueueZmqImpl.cpp src/impl/servers/Microservice_IMsgQueueZmqImpl.h)
target_link_libraries(Microservice ${PROJECT_LINK_LIBS} )
set_target_properties(Microservice PROPERTIES VERSION ${Microservice_VERSION_STRING}
SOVERSION ${Microservice_VERSION_MAJOR})
......
......@@ -6,4 +6,4 @@
# Created on May 8, 2016, 9:59:18 AM
#
sudo apt-get install -y libhiredis0.10 libhiredis-dev libzmq3 libzmq3-dev liblog4cpp5 liblog4cpp5-dev \
libgoogle-glog-dev libboost-all-dev libssl-dev
\ No newline at end of file
libgoogle-glog-dev libboost-all-dev libssl-dev uuid-dev libpcre3-dev valgrind
\ No newline at end of file
......@@ -29,6 +29,7 @@ private:
cMicroservice_BaseHandler* mpc_Handler;
nsMicroservice_Iface::ILogger* mpc_Logger;
nsMicroservice_Iface::IPubSub* mpc_PubSub;
cMicroservice_RequestContext* mpc_RequestContext;
char mba_Buff[nsMicroservice_Constants::MAX_URI_LENGTH];
char mba_ErrorBuff[nsMicroservice_Constants::MAX_ERROR_BUFF_URI_LENGTH];
......
//
// Created by amir on 13/11/16.
//
#include "Microservice_IMsgQueueZmqImpl.h"
MSRetStat
Microservice_IMsgQueueZmqImpl::Send(std::string &t_Message, nsMicroservice_Iface::IMsgQueue::IDestination *p_Dest) {
return MSRetStat();
}
MSRetStat Microservice_IMsgQueueZmqImpl::Receive(std::string &t_Message) {
return MSRetStat();
}
//
// Created by amir on 13/11/16.
//
#ifndef MICROSERVICE_MICROSERVICE_IMSGQUEUEZMQIMPL_H
#define MICROSERVICE_MICROSERVICE_IMSGQUEUEZMQIMPL_H
#include <Microservice_Iface.h>
class Microservice_IMsgQueueZmqImpl : public nsMicroservice_Iface::IMsgQueue {
public:
class ZMQDestination: public nsMicroservice_Iface::IMsgQueue::IDestination
{
};
public:
virtual MSRetStat Send(std::string &t_Message, IDestination *p_Dest) override;
virtual MSRetStat Receive(std::string &t_Message) override;
};
typedef std::shared_ptr<Microservice_IMsgQueueZmqImpl::ZMQDestination> ZmqDestinationPtr;
#endif //MICROSERVICE_MICROSERVICE_IMSGQUEUEZMQIMPL_H
......@@ -36,11 +36,15 @@ public:
}
void DoCreate(cMicroservice_RequestContext* pc_reqCtx)
{
rapidjson::Document rpj_Doc;
if (this->ReadObjectFromRequest(pc_reqCtx,rpj_Doc) )
this->WriteObjectToResponse(pc_reqCtx,rpj_Doc);
else
this->SendErrorResp(pc_reqCtx,"Error in parsing json");
if (pc_reqCtx->mc_QueryParameters.empty())
CreateSync(pc_reqCtx);
else {
rapidjson::Document rpj_Doc;
if (this->ReadObjectFromRequest(pc_reqCtx,rpj_Doc) )
this->WriteObjectToResponse(pc_reqCtx,rpj_Doc);
else
this->SendErrorResp(pc_reqCtx,"Error in parsing json");
}
}
void DoRead(cMicroservice_RequestContext* pc_reqCtx)
......@@ -85,6 +89,25 @@ public:
SendErrorResp(pc_reqCtx, retstat.GetError());
}
void CreateSync(cMicroservice_RequestContext *pc_reqCtx) {
Microservice_RestResponse rest_response;
std::map<std::string,std::string> headers;
headers["X-IPgallery"] = "OK";
MSCommandParams cmd_params;
cmd_params
//.WithEntity("http://httpbin.org/post")
.WithEntity("http://172.16.1.151:50010/nse/auth")
//.WithParamsString("login")
.WithRequestParams("key=123")
.EnableAsync(false);
MSRetStat retstat = p_client_->Read(&cmd_params, &rest_response);
if(retstat.IsSuccess())
WriteObjectToResponse(pc_reqCtx, rest_response);
else
SendErrorResp(pc_reqCtx, retstat.GetError());
}
void DoUpdate(cMicroservice_RequestContext* pc_reqCtx)
{
}
......@@ -247,7 +270,7 @@ TO testDocs()
cMicroservice_BaseRestResponse resp;
if (resp.GetObjectNode().IsNull()) { std::cout << "empty\n"; }
rapidjson::Document& rpj_Doc = resp.GetObjectNode();
rapidjson::Document& rpj_Doc = resp.GetObjectNode();
rapidjson::Document::AllocatorType& rpj_Alloc = rpj_Doc.GetAllocator();
rpj_Doc.SetObject();
if (resp.GetObjectNode().IsNull()) { std::cout << "empty\n"; }
......
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