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
5faab7bf
authored
Jan 29, 2020
by
Amir Aharon
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
first copiling version
parent
4cbd20fb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
16 deletions
.vscode/c_cpp_properties.json
CMakeLists.txt
doc/install-dependencies.sh
src/Microservice_App.cpp
src/impl/Microservice_ILoggerSpdlogImpl.cpp
test/Microservice_ClientTest.cpp
.vscode/c_cpp_properties.json
View file @
5faab7bf
...
@@ -41,7 +41,8 @@
...
@@ -41,7 +41,8 @@
"${workspaceRoot}/src"
,
"${workspaceRoot}/src"
,
"/usr/include/c++/7.4.0"
,
"/usr/include/c++/7.4.0"
,
"/usr/include/x86_64-linux-gnu/c++/7.4.0"
,
"/usr/include/x86_64-linux-gnu/c++/7.4.0"
,
"${workspaceRoot}/../3party/cereal/include"
"${workspaceRoot}/../3party/cereal/include"
,
"${workspaceRoot}/../3party/spdlog/include"
],
],
"compileCommands"
:
"./compile_commands.json"
,
"compileCommands"
:
"./compile_commands.json"
,
"defines"
:
[],
"defines"
:
[],
...
...
CMakeLists.txt
View file @
5faab7bf
...
@@ -20,7 +20,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
...
@@ -20,7 +20,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set
(
PROJECT_LINK_LIBS -lPocoFoundation -ljson -lhiredis -lcpprest -lcppmetrics -lboost_random -lboost_timer -lboost_chrono
set
(
PROJECT_LINK_LIBS -lPocoFoundation -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 -l
log4cpp -lglog -l
zmqpp -lzmq -levpp -levent
)
-lcrypto -lzmqpp -lzmq -levpp -levent
)
# set ( PROJECT_LINK_LIBS -lPocoFoundation -ljson -lhiredis -lcpprest -lcppmetrics -lboost_random -lboost_timer -lboost_chrono
# set ( PROJECT_LINK_LIBS -lPocoFoundation -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
...
@@ -36,12 +36,12 @@ include_directories(SYSTEM ../3party/rapidjson-cereal-1.2.1)
...
@@ -36,12 +36,12 @@ include_directories(SYSTEM ../3party/rapidjson-cereal-1.2.1)
#include_directories(SYSTEM ../3party/rapidjson-0.11/include/rapidjson)
#include_directories(SYSTEM ../3party/rapidjson-0.11/include/rapidjson)
include_directories
(
SYSTEM ../3party/cppmetrics-0.1.1-Linux/include
)
include_directories
(
SYSTEM ../3party/cppmetrics-0.1.1-Linux/include
)
include_directories
(
SYSTEM ../3party/civetweb/include
)
include_directories
(
SYSTEM ../3party/civetweb/include
)
include_directories
(
SYSTEM ../3party/cpprest/Release/include
)
#
include_directories(SYSTEM ../3party/cpprest/Release/include)
include_directories
(
SYSTEM ../3party/rabbitmq
)
include_directories
(
SYSTEM ../3party/rabbitmq
)
include_directories
(
SYSTEM ../3party/flatbuffers/include
)
include_directories
(
SYSTEM ../3party/flatbuffers/include
)
include_directories
(
SYSTEM ../3party/poco-1.7.8/Foundation/include
)
#
include_directories(SYSTEM ../3party/poco-1.7.8/Foundation/include)
include_directories
(
SYSTEM ../3party/evpp/build-release/include
)
include_directories
(
SYSTEM ../3party/evpp/build-release/include
)
include_directories
(
SYSTEM ../3party/spdlog/include
/spdlog
)
include_directories
(
SYSTEM ../3party/spdlog/include
)
# include_directories(SYSTEM ../internals/include/Rabbitmq)
# include_directories(SYSTEM ../internals/include/Rabbitmq)
include_directories
(
SYSTEM /usr/include/Poco
)
include_directories
(
SYSTEM /usr/include/Poco
)
include_directories
(
SYSTEM /usr/include/hiredis
)
include_directories
(
SYSTEM /usr/include/hiredis
)
...
@@ -56,13 +56,16 @@ get_filename_component(RMQRequest_file_path ${CMAKE_CURRENT_SOURCE_DIR}/src/impl
...
@@ -56,13 +56,16 @@ get_filename_component(RMQRequest_file_path ${CMAKE_CURRENT_SOURCE_DIR}/src/impl
get_filename_component
(
RMQResponse_file_path
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/impl/Microservice_IResponseRMQImpl.cpp ABSOLUTE
)
get_filename_component
(
RMQResponse_file_path
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/impl/Microservice_IResponseRMQImpl.cpp ABSOLUTE
)
get_filename_component
(
RMQServer_file_path
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/impl/servers/Microservice_IRestServerRMQImpl.cpp ABSOLUTE
)
get_filename_component
(
RMQServer_file_path
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/impl/servers/Microservice_IRestServerRMQImpl.cpp ABSOLUTE
)
get_filename_component
(
RMQClient_file_path
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/impl/clients/MSICommandClientRMQImpl.cpp ABSOLUTE
)
get_filename_component
(
RMQClient_file_path
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/impl/clients/MSICommandClientRMQImpl.cpp ABSOLUTE
)
get_filename_component
(
LOG4Cpp_file_path
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/impl/Microservices_ILoggerLog4cppImpl.cpp ABSOLUTE
)
message
(
"
${
RMQHandler_file_path
}
"
)
message
(
"
${
RMQHandler_file_path
}
"
)
list
(
REMOVE_ITEM SOURCES
"
${
RMQHandler_file_path
}
"
list
(
REMOVE_ITEM SOURCES
"
${
RMQHandler_file_path
}
"
"
${
RMQRequest_file_path
}
"
"
${
RMQRequest_file_path
}
"
"
${
RMQResponse_file_path
}
"
"
${
RMQResponse_file_path
}
"
"
${
RMQServer_file_path
}
"
"
${
RMQServer_file_path
}
"
"
${
RMQClient_file_path
}
"
)
"
${
RMQClient_file_path
}
"
"
${
LOG4Cpp_file_path
}
"
)
message
(
"
${
SOURCES
}
"
)
message
(
"
${
SOURCES
}
"
)
#Generate the shared library from the sources
#Generate the shared library from the sources
...
@@ -137,7 +140,7 @@ INSTALL( DIRECTORY ../3party/rapidjson-cereal-1.2.1 DESTINATION include/3party )
...
@@ -137,7 +140,7 @@ INSTALL( DIRECTORY ../3party/rapidjson-cereal-1.2.1 DESTINATION include/3party )
INSTALL
(
DIRECTORY ../3party/cppmetrics-0.1.1-Linux/include DESTINATION include/3party/cppmetrics
)
INSTALL
(
DIRECTORY ../3party/cppmetrics-0.1.1-Linux/include DESTINATION include/3party/cppmetrics
)
file
(
GLOB INSTALL_FILES
"../3party/mongoose/mongoose.*"
)
file
(
GLOB INSTALL_FILES
"../3party/mongoose/mongoose.*"
)
install
(
FILES
${
INSTALL_FILES
}
DESTINATION include/3party/mongoose
)
install
(
FILES
${
INSTALL_FILES
}
DESTINATION include/3party/mongoose
)
INSTALL
(
DIRECTORY ../3party/cpprest/Release/include DESTINATION include/3party/cpprest
)
#
INSTALL( DIRECTORY ../3party/cpprest/Release/include DESTINATION include/3party/cpprest )
INSTALL
(
DIRECTORY ../3party/evpp/build-release/include DESTINATION include/3party/evpp
)
INSTALL
(
DIRECTORY ../3party/evpp/build-release/include DESTINATION include/3party/evpp
)
INSTALL
(
DIRECTORY ../3party/rabbitmq DESTINATION include/3party
)
INSTALL
(
DIRECTORY ../3party/rabbitmq DESTINATION include/3party
)
#INSTALL( DIRECTORY ../internals/include/Rabbitmq DESTINATION include/internals )
#INSTALL( DIRECTORY ../internals/include/Rabbitmq DESTINATION include/internals )
...
...
doc/install-dependencies.sh
View file @
5faab7bf
...
@@ -9,4 +9,5 @@
...
@@ -9,4 +9,5 @@
# libgoogle-glog-dev libboost-all-dev libssl-dev uuid-dev libzmqpp-dev libmhash-dev libevent-dev
# libgoogle-glog-dev libboost-all-dev libssl-dev uuid-dev libzmqpp-dev libmhash-dev libevent-dev
apt-get install
-y
libhiredis-dev libzmq3-dev liblog4cpp5-dev
\
apt-get install
-y
libhiredis-dev libzmq3-dev liblog4cpp5-dev
\
libgoogle-glog-dev libboost-all-dev libssl-dev uuid-dev libzmqpp-dev libmhash-dev libevent-dev
libgoogle-glog-dev libboost-all-dev libssl-dev uuid-dev libzmqpp-dev libmhash-dev libevent-dev
\
\ No newline at end of file
libpoco-dev libcpprest-dev
\ No newline at end of file
src/Microservice_App.cpp
View file @
5faab7bf
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
#include <handlers/Microservice_MonitorHandler.h>
#include <handlers/Microservice_MonitorHandler.h>
#include <algorithm>
#include <algorithm>
#include <Microservice_Client.h>
#include <Microservice_Client.h>
#include <impl/Microservice
s_ILoggerLog4cpp
Impl.h>
#include <impl/Microservice
_ILoggerSpdlog
Impl.h>
#include <impl/Microservice_IConfigurationConfigPropImpl.h>
#include <impl/Microservice_IConfigurationConfigPropImpl.h>
#include <chrono>
#include <chrono>
#include <condition_variable>
#include <condition_variable>
...
@@ -269,7 +269,8 @@ Microservice_App& Microservice_App::build() {
...
@@ -269,7 +269,8 @@ Microservice_App& Microservice_App::build() {
// init default logger if there is none
// init default logger if there is none
if
(
mpc_Logger
==
nullptr
)
if
(
mpc_Logger
==
nullptr
)
mpc_Logger
=
new
cMicroservices_ILoggerLog4cppImpl
(
mc_AppName
.
c_str
());
// default logger
//mpc_Logger = new cMicroservices_ILoggerLog4cppImpl(mc_AppName.c_str()); // default logger
mpc_Logger
=
new
Microservice_ILoggerSpdlogImpl
(
mc_AppName
.
c_str
());
// default logger
/*
/*
...
...
src/impl/Microservice_ILoggerSpdlogImpl.cpp
View file @
5faab7bf
#include "Microservice_ILoggerSpdlogImpl.h"
#include "Microservice_ILoggerSpdlogImpl.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include <spdlog/sinks/stdout_color_sinks.h>
thread_local
char
ba_LogBuffer
[
nsMicroservice_Constants
::
MAX_LOGEER_BUFF_LENGTH
];
#define MAKE_MESSAGE {int len; va_list ap; va_start( ap , stringFormat );\
#define MAKE_MESSAGE {int len; va_list ap; va_start( ap , stringFormat );\
len = ( vsnprintf(ba_LogBuffer, nsMicroservice_Constants::MAX_LOGEER_BUFF_LENGTH, stringFormat, ap ) ); va_end(ap);}
len = ( vsnprintf(ba_LogBuffer, nsMicroservice_Constants::MAX_LOGEER_BUFF_LENGTH, stringFormat, ap ) ); va_end(ap);}
...
...
test/Microservice_ClientTest.cpp
View file @
5faab7bf
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
// #include <impl/clients/MSICommandClientRMQImpl.h>
// #include <impl/clients/MSICommandClientRMQImpl.h>
#include "impl/Microservices_ILoggerLog4cppImpl.h"
#include <utils/ClientFactory.h>
#include <utils/ClientFactory.h>
#include <utils/CommonUtils.h>
#include <utils/CommonUtils.h>
#include <flatbuffers/flatbuffers.h>
#include <flatbuffers/flatbuffers.h>
...
@@ -572,12 +571,12 @@ void runMSClientEvppTest(){
...
@@ -572,12 +571,12 @@ void runMSClientEvppTest(){
static
int
responsed
=
0
;
static
int
responsed
=
0
;
static
void
HandleHTTPResponse
(
const
std
::
shared_ptr
<
evpp
::
httpc
::
EvppResponse
>&
response
,
evpp
::
httpc
::
PostEvppRequest
*
request
)
{
static
void
HandleHTTPResponse
(
const
std
::
shared_ptr
<
evpp
::
httpc
::
EvppResponse
>&
response
,
evpp
::
httpc
::
PostEvppRequest
*
request
)
{
LOG_INFO
<<
"http_code="
<<
response
->
http_code
()
std
::
cout
<<
"http_code="
<<
response
->
http_code
()
<<
" URL=http://"
<<
request
->
host
()
<<
request
->
uri
()
<<
" URL=http://"
<<
request
->
host
()
<<
request
->
uri
()
<<
" BODY = ["
<<
response
->
body
().
ToString
()
<<
"]"
;
<<
" BODY = ["
<<
response
->
body
().
ToString
()
<<
"]"
;
const
char
*
header
=
response
->
FindHeader
(
"Connection"
);
const
char
*
header
=
response
->
FindHeader
(
"Connection"
);
if
(
header
)
{
if
(
header
)
{
LOG_INFO
<<
"HTTP HEADER Connection="
<<
header
;
std
::
cout
<<
"HTTP HEADER Connection="
<<
header
;
}
}
responsed
++
;
responsed
++
;
assert
(
request
==
response
->
request
());
assert
(
request
==
response
->
request
());
...
@@ -601,7 +600,7 @@ void test_evpp(){
...
@@ -601,7 +600,7 @@ void test_evpp(){
}
}
t
.
Stop
(
true
);
t
.
Stop
(
true
);
LOG_INFO
<<
"EventLoopThread stopped."
;
std
::
cout
<<
"EventLoopThread stopped."
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
...
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