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
e71f2950
authored
Jan 25, 2018
by
Amir Aharon
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
first testing of Evpp
parent
35304c19
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
5 deletions
src/impl/servers/Microservice_IRestServerEvppImpl.cpp
src/impl/servers/Microservice_IRestServerEvppImpl.h
src/utils/ServerFactory.cpp
src/utils/ServerFactory.h
test/Microservice_Test.cpp
src/impl/servers/Microservice_IRestServerEvppImpl.cpp
View file @
e71f2950
...
@@ -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
;
...
...
src/impl/servers/Microservice_IRestServerEvppImpl.h
View file @
e71f2950
...
@@ -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
)
{}
...
...
src/utils/ServerFactory.cpp
View file @
e71f2950
...
@@ -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
));
...
...
src/utils/ServerFactory.h
View file @
e71f2950
...
@@ -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
);
...
...
test/Microservice_Test.cpp
View file @
e71f2950
...
@@ -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
())
...
...
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