Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.cpp
/
Microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e0cb4bb9
authored
Nov 14, 2016
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
start working on feature
parent
7b356122
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
75 additions
and
10 deletions
CMakeLists.txt
doc/install-dependencies.sh
src/Microservice_Iface.h
src/handlers/Microservice_RestHandler.h
src/impl/servers/Microservice_IMsgQueueZmqImpl.cpp
src/impl/servers/Microservice_IMsgQueueZmqImpl.h
test/Microservice_Test.cpp
CMakeLists.txt
View file @
e0cb4bb9
...
@@ -18,7 +18,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
...
@@ -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
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_system -lboost_thread -lboost_date_time -lboost_regex -lboost_filesystem -lpthread
-lboost_random -lboost_chrono -lboost_system -lboost_thread -lssl
-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
(
../3party/lib
)
link_directories
(
../internals/lib
)
link_directories
(
../internals/lib
)
...
@@ -31,12 +31,13 @@ include_directories(SYSTEM ../3party/cpprest/Release/include)
...
@@ -31,12 +31,13 @@ include_directories(SYSTEM ../3party/cpprest/Release/include)
include_directories
(
SYSTEM ../3party/rabbitmq
)
include_directories
(
SYSTEM ../3party/rabbitmq
)
include_directories
(
SYSTEM ../internals/include/Rabbitmq
)
include_directories
(
SYSTEM ../internals/include/Rabbitmq
)
include_directories
(
SYSTEM /usr/include/hiredis
)
include_directories
(
SYSTEM /usr/include/hiredis
)
include_directories
(
SYSTEM ../3party/czmq-4.0.0/include
)
# recursive search files cpp files
# recursive search files cpp files
file
(
GLOB_RECURSE SOURCES
"src/*.cpp"
)
file
(
GLOB_RECURSE SOURCES
"src/*.cpp"
)
set
(
3PARTY_SOURCES ../3party/mongoose/mongoose.c
)
set
(
3PARTY_SOURCES ../3party/mongoose/mongoose.c
)
#Generate the shared library from the sources
#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
}
)
target_link_libraries
(
Microservice
${
PROJECT_LINK_LIBS
}
)
set_target_properties
(
Microservice PROPERTIES VERSION
${
Microservice_VERSION_STRING
}
set_target_properties
(
Microservice PROPERTIES VERSION
${
Microservice_VERSION_STRING
}
SOVERSION
${
Microservice_VERSION_MAJOR
}
)
SOVERSION
${
Microservice_VERSION_MAJOR
}
)
...
...
doc/install-dependencies.sh
View file @
e0cb4bb9
...
@@ -6,4 +6,4 @@
...
@@ -6,4 +6,4 @@
# Created on May 8, 2016, 9:59:18 AM
# Created on May 8, 2016, 9:59:18 AM
#
#
sudo
apt-get install
-y
libhiredis0.10 libhiredis-dev libzmq3 libzmq3-dev liblog4cpp5 liblog4cpp5-dev
\
sudo
apt-get install
-y
libhiredis0.10 libhiredis-dev libzmq3 libzmq3-dev liblog4cpp5 liblog4cpp5-dev
\
libgoogle-glog-dev libboost-all-dev libssl-dev
libgoogle-glog-dev libboost-all-dev libssl-dev uuid-dev libpcre3-dev valgrind
\ No newline at end of file
\ No newline at end of file
src/Microservice_Iface.h
View file @
e0cb4bb9
This diff is collapsed.
Click to expand it.
src/handlers/Microservice_RestHandler.h
View file @
e0cb4bb9
...
@@ -29,6 +29,7 @@ private:
...
@@ -29,6 +29,7 @@ private:
cMicroservice_BaseHandler
*
mpc_Handler
;
cMicroservice_BaseHandler
*
mpc_Handler
;
nsMicroservice_Iface
::
ILogger
*
mpc_Logger
;
nsMicroservice_Iface
::
ILogger
*
mpc_Logger
;
nsMicroservice_Iface
::
IPubSub
*
mpc_PubSub
;
nsMicroservice_Iface
::
IPubSub
*
mpc_PubSub
;
cMicroservice_RequestContext
*
mpc_RequestContext
;
cMicroservice_RequestContext
*
mpc_RequestContext
;
char
mba_Buff
[
nsMicroservice_Constants
::
MAX_URI_LENGTH
];
char
mba_Buff
[
nsMicroservice_Constants
::
MAX_URI_LENGTH
];
char
mba_ErrorBuff
[
nsMicroservice_Constants
::
MAX_ERROR_BUFF_URI_LENGTH
];
char
mba_ErrorBuff
[
nsMicroservice_Constants
::
MAX_ERROR_BUFF_URI_LENGTH
];
...
...
src/impl/servers/Microservice_IMsgQueueZmqImpl.cpp
0 → 100644
View file @
e0cb4bb9
//
// 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
();
}
src/impl/servers/Microservice_IMsgQueueZmqImpl.h
0 → 100644
View file @
e0cb4bb9
//
// 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
test/Microservice_Test.cpp
View file @
e0cb4bb9
...
@@ -36,11 +36,15 @@ public:
...
@@ -36,11 +36,15 @@ public:
}
}
void
DoCreate
(
cMicroservice_RequestContext
*
pc_reqCtx
)
void
DoCreate
(
cMicroservice_RequestContext
*
pc_reqCtx
)
{
{
rapidjson
::
Document
rpj_Doc
;
if
(
pc_reqCtx
->
mc_QueryParameters
.
empty
())
if
(
this
->
ReadObjectFromRequest
(
pc_reqCtx
,
rpj_Doc
)
)
CreateSync
(
pc_reqCtx
);
this
->
WriteObjectToResponse
(
pc_reqCtx
,
rpj_Doc
);
else
{
else
rapidjson
::
Document
rpj_Doc
;
this
->
SendErrorResp
(
pc_reqCtx
,
"Error in parsing json"
);
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
)
void
DoRead
(
cMicroservice_RequestContext
*
pc_reqCtx
)
...
@@ -85,6 +89,25 @@ public:
...
@@ -85,6 +89,25 @@ public:
SendErrorResp
(
pc_reqCtx
,
retstat
.
GetError
());
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
)
void
DoUpdate
(
cMicroservice_RequestContext
*
pc_reqCtx
)
{
{
}
}
...
@@ -247,7 +270,7 @@ TO testDocs()
...
@@ -247,7 +270,7 @@ TO testDocs()
cMicroservice_BaseRestResponse
resp
;
cMicroservice_BaseRestResponse
resp
;
if
(
resp
.
GetObjectNode
().
IsNull
())
{
std
::
cout
<<
"empty
\n
"
;
}
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
();
rapidjson
::
Document
::
AllocatorType
&
rpj_Alloc
=
rpj_Doc
.
GetAllocator
();
rpj_Doc
.
SetObject
();
rpj_Doc
.
SetObject
();
if
(
resp
.
GetObjectNode
().
IsNull
())
{
std
::
cout
<<
"empty
\n
"
;
}
if
(
resp
.
GetObjectNode
().
IsNull
())
{
std
::
cout
<<
"empty
\n
"
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment