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
22c972c4
authored
Jan 22, 2018
by
Amir Aharon
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
end of day: add libevent to develop image and some evpp code
parent
8ef5aa9c
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
10 deletions
.vscode/c_cpp_properties.json
.vscode/tasks.json
CMakeLists.txt
README.md
doc/install-dependencies.sh
src/impl/servers/Microservice_IRestServerEvppImpl.cpp
src/impl/servers/Microservice_IRestServerEvppImpl.h
.vscode/c_cpp_properties.json
View file @
22c972c4
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
"/usr/include/x86_64-linux-gnu"
,
"/usr/include/x86_64-linux-gnu"
,
"/usr/include"
,
"/usr/include"
,
"${workspaceRoot}/../3party"
,
"${workspaceRoot}/../3party"
,
"${workspaceRoot}/../3party/evpp/build-release/include"
,
"${workspaceRoot}/src"
"${workspaceRoot}/src"
],
],
"defines"
:
[],
"defines"
:
[],
...
...
.vscode/tasks.json
View file @
22c972c4
...
@@ -32,7 +32,10 @@
...
@@ -32,7 +32,10 @@
{
{
"label"
:
"clean"
,
"label"
:
"clean"
,
"type"
:
"shell"
,
"type"
:
"shell"
,
"command"
:
"docker exec -it devenv make clean"
"command"
:
"docker exec -it devenv make clean"
,
"problemMatcher"
:
[
"$gcc"
]
},
},
{
{
"label"
:
"start-gdbserver"
,
"label"
:
"start-gdbserver"
,
...
@@ -40,6 +43,13 @@
...
@@ -40,6 +43,13 @@
//
not
using
-it
so
that
it
can
be
a
preLaunchTask
//
not
using
-it
so
that
it
can
be
a
preLaunchTask
"command"
:
"docker exec -d devenv gdbserver :2000 bin/test_Microservice"
,
"command"
:
"docker exec -d devenv gdbserver :2000 bin/test_Microservice"
,
"problemMatcher"
:
[]
"problemMatcher"
:
[]
},
{
"label"
:
"build develop image"
,
"type"
:
"shell"
,
//
not
using
-it
so
that
it
can
be
a
preLaunchTask
"command"
:
"docker build -t municipalitybank.com:5050/ipgallery.common.cpp/microservice/develop ."
,
"problemMatcher"
:
[]
}
}
]
]
}
}
\ No newline at end of file
CMakeLists.txt
View file @
22c972c4
...
@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 2.8.12)
...
@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 2.8.12)
project
(
Microservice
)
project
(
Microservice
)
# version stuff
# version stuff
set
(
Microservice_VERSION_MAJOR 1
)
set
(
Microservice_VERSION_MAJOR 1
)
set
(
Microservice_VERSION_MINOR
4
)
set
(
Microservice_VERSION_MINOR
5
)
set
(
Microservice_VERSION_PATCH
2
)
set
(
Microservice_VERSION_PATCH
0
)
set
(
Microservice_VERSION_STRING
${
Microservice_VERSION_MAJOR
}
.
${
Microservice_VERSION_MINOR
}
.
${
Microservice_VERSION_PATCH
}
)
set
(
Microservice_VERSION_STRING
${
Microservice_VERSION_MAJOR
}
.
${
Microservice_VERSION_MINOR
}
.
${
Microservice_VERSION_PATCH
}
)
# type build flags
# type build flags
...
@@ -19,7 +19,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
...
@@ -19,7 +19,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
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 -llog4cpp -lglog -lzmqpp -lzmq
)
-lcrypto -llog4cpp -lglog -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
...
...
README.md
View file @
22c972c4
## C++ Microservice Framework
## C++ Microservice Framework
## VERSIONS:
## VERSIONS:
# 1.5.0
-
add new rest server Evpp
# 1.4.2
# 1.4.2
-
moving to municipalitybank.com cloud
-
moving to municipalitybank.com cloud
# 1.4.1
# 1.4.1
...
...
doc/install-dependencies.sh
View file @
22c972c4
...
@@ -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 uuid-dev libzmqpp-dev libmhash-dev
libgoogle-glog-dev libboost-all-dev libssl-dev uuid-dev libzmqpp-dev libmhash-dev libevent-2.0
\ No newline at end of file
\ No newline at end of file
src/impl/servers/Microservice_IRestServerEvppImpl.cpp
View file @
22c972c4
...
@@ -4,9 +4,17 @@
...
@@ -4,9 +4,17 @@
static
int
s_sig_num
=
0
;
static
int
s_sig_num
=
0
;
void
run_thread
(
Microservice_IRestServerEvppImpl
*
pc_Obj
)
void
DefaultHandler
(
evpp
::
EventLoop
*
loop
,
{
const
evpp
::
http
::
ContextPtr
&
ctx
,
pc_Obj
->
start
();
const
evpp
::
http
::
HTTPSendResponseCallback
&
cb
)
{
std
::
stringstream
oss
;
oss
<<
"func="
<<
__FUNCTION__
<<
" OK"
<<
" ip="
<<
ctx
->
remote_ip
()
<<
"
\n
"
<<
" uri="
<<
ctx
->
uri
()
<<
"
\n
"
<<
" body="
<<
ctx
->
body
().
ToString
()
<<
"
\n
"
;
ctx
->
AddResponseHeader
(
"Content-Type"
,
"application/octet-stream"
);
ctx
->
AddResponseHeader
(
"Server"
,
"evpp"
);
cb
(
oss
.
str
());
}
}
static
void
signal_handler
(
int
sig_num
)
{
static
void
signal_handler
(
int
sig_num
)
{
...
@@ -28,12 +36,23 @@ bool Microservice_IRestServerEvppImpl::build(std::string& appName, const std::ma
...
@@ -28,12 +36,23 @@ bool Microservice_IRestServerEvppImpl::build(std::string& appName, const std::ma
nsMicroservice_Iface
::
IMetricsFactory
*
p_metrics_factory
){
nsMicroservice_Iface
::
IMetricsFactory
*
p_metrics_factory
){
bool
result
=
false
;
bool
result
=
false
;
if
(
p_param_
)
{
appName_
.
assign
(
appName
);
p_logger_
=
pc_Logger
;
signal
(
SIGINT
,
signal_handler
);
signal
(
SIGTERM
,
signal_handler
);
result
=
true
;
}
return
result
;
return
result
;
}
}
void
Microservice_IRestServerEvppImpl
::
registerService
(
nsMicroservice_Iface
::
IServiceDiscovery
*
pc_ServiceDiscovery
,
void
Microservice_IRestServerEvppImpl
::
registerService
(
nsMicroservice_Iface
::
IServiceDiscovery
*
pc_ServiceDiscovery
,
std
::
string
&
id
){
std
::
string
&
id
){
if
(
pc_ServiceDiscovery
!=
nullptr
)
pc_ServiceDiscovery
->
registerService
(
appName_
,
id
,
p_param_
->
getHost
(),
p_param_
->
getPort
());
}
}
void
Microservice_IRestServerEvppImpl
::
run
(){
void
Microservice_IRestServerEvppImpl
::
run
(){
...
@@ -48,5 +67,9 @@ void Microservice_IRestServerEvppImpl::stop(){
...
@@ -48,5 +67,9 @@ void Microservice_IRestServerEvppImpl::stop(){
}
}
bool
Microservice_IRestServerEvppImpl
::
init
(){
bool
Microservice_IRestServerEvppImpl
::
init
(){
p_server_
=
new
evpp
::
http
::
Server
(
p_param_
->
getWorkerThreadsNum
());
p_server_
->
SetThreadDispatchPolicy
(
evpp
::
ThreadDispatchPolicy
::
kIPAddressHashing
);
p_server_
->
RegisterDefaultHandler
(
&
DefaultHandler
);
return
true
;
return
true
;
}
}
\ No newline at end of file
src/impl/servers/Microservice_IRestServerEvppImpl.h
View file @
22c972c4
...
@@ -7,6 +7,77 @@
...
@@ -7,6 +7,77 @@
#include <thread>
#include <thread>
#include <evpp/http/http_server.h>
#include <evpp/http/http_server.h>
class
Microservice_IResponseRestEvppImpl
:
public
nsMicroservice_Iface
::
IResponse
{
// for cloning
// Microservice_IResponseRestEvppImpl() :
// // p_respConnection_(p_respConnection),
// // respBuilder_(nsMicroservice_Constants::REQUEST_MSG_INITIAL_SIZE),
// rcid_(0)
// {}
//Evpppp::socket* p_respConnection_;
std
::
uint64_t
rcid_
;
public
:
Microservice_IResponseRestEvppImpl
()
:
rcid_
(
0
)
{}
void
Send
(
const
char
*
response
)
override
{
// if (p_respConnection_) {
// /**
// * building restresponse msg
// */
// respBuilder_.Clear();
// auto restResponse = common::context::CreateRestResponseDirect(respBuilder_,rcid_,response);
// respBuilder_.Finish(restResponse);
// p_respConnection_->send_raw((const char *) respBuilder_.GetBufferPointer(), respBuilder_.GetSize(), Evpppp::socket::dont_wait);
// }
}
void
Reset
()
override
{
/*p_respConnection_ = nullptr; */
}
void
setParams
(
/*Evpppp::socket *p_respConnection, */
std
::
uint64_t
rcid
)
{
//p_respConnection_ = p_respConnection;
rcid_
=
rcid
;
}
virtual
nsMicroservice_Iface
::
IResponse
*
clone
()
override
{
return
new
Microservice_IResponseRestEvppImpl
();
}
};
class
Microservice_IRequestRestEvppImpl
:
public
nsMicroservice_Iface
::
IRequest
{
public
:
Microservice_IRequestRestEvppImpl
()
{}
const
char
*
GetQueryString
()
override
{
// if (p_restMsg_)
// return p_restMsg_->queryString()->c_str();
return
nullptr
;
}
const
char
*
GetRelativePath
()
override
{
// if (p_restMsg_)
// return p_restMsg_->url()->c_str();
return
nullptr
;
}
const
char
*
GetContent
()
override
{
// if (p_restMsg_)
// return p_restMsg_->content()->c_str();
return
nullptr
;
}
void
Reset
()
override
{
// p_restMsg_ = nullptr;
}
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
);
...
@@ -32,6 +103,7 @@ private:
...
@@ -32,6 +103,7 @@ private:
nsMicroservice_Iface
::
ILogger
*
p_logger_
;
nsMicroservice_Iface
::
ILogger
*
p_logger_
;
std
::
string
serverType_
;
std
::
string
serverType_
;
cMicroservice_RestServerParams
*
p_param_
;
cMicroservice_RestServerParams
*
p_param_
;
std
::
string
appName_
;
// consts
// consts
static
constexpr
uint32_t
SLEEP_INTERVAL
=
1
;
//useconds
static
constexpr
uint32_t
SLEEP_INTERVAL
=
1
;
//useconds
...
...
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