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
22805a1c
authored
Mar 07, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add binary serializer and IConnection
ver 1.1.0
parent
b7df6507
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
5 deletions
CMakeLists.txt
src/Microservice_Client.h
src/common/Microservice_Iface.h
src/impl/Microservice_IMsgArchiverCerealImpls.h
src/impl/clients/MSICommandClientHttpImpl.cpp
src/impl/servers/Microservice_IRestServerMongooseImpl.cpp
test/Microservice_ZMQTest.cpp
CMakeLists.txt
View file @
22805a1c
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)
...
@@ -2,7 +2,7 @@ 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
0
)
set
(
Microservice_VERSION_MINOR
1
)
set
(
Microservice_VERSION_PATCH 0
)
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
}
)
...
@@ -92,6 +92,9 @@ install(FILES ${INSTALL_FILES} DESTINATION include/microservice/impl/servers)
...
@@ -92,6 +92,9 @@ install(FILES ${INSTALL_FILES} DESTINATION include/microservice/impl/servers)
# src/handlers
# src/handlers
file
(
GLOB INSTALL_FILES
"src/handlers/*.h"
)
file
(
GLOB INSTALL_FILES
"src/handlers/*.h"
)
install
(
FILES
${
INSTALL_FILES
}
DESTINATION include/microservice/handlers
)
install
(
FILES
${
INSTALL_FILES
}
DESTINATION include/microservice/handlers
)
# src/utils
file
(
GLOB INSTALL_FILES
"src/utils/*.h"
)
install
(
FILES
${
INSTALL_FILES
}
DESTINATION include/microservice/utils
)
...
...
src/Microservice_Client.h
View file @
22805a1c
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
using
namespace
nsMicroservice_Iface
;
using
namespace
nsMicroservice_Iface
;
typedef
std
::
shared_ptr
<
cMicroservice_BaseRestResponse
>
BaseResponsePtr
;
typedef
std
::
shared_ptr
<
cMicroservice_BaseRestResponse
>
BaseResponsePtr
;
typedef
std
::
shared_ptr
<
MSCommandParams
>
MSCommandParamsPtr
;
typedef
std
::
shared_ptr
<
MSCommandParams
>
MSCommandParamsPtr
;
typedef
std
::
shared_ptr
<
IResponse
>
IResponsePtr
;
typedef
std
::
shared_ptr
<
IResponse
>
IResponsePtr
;
...
@@ -72,6 +71,7 @@ struct ClientAsyncTaskParams
...
@@ -72,6 +71,7 @@ struct ClientAsyncTaskParams
typedef
std
::
shared_ptr
<
ClientAsyncTaskParams
>
ClientAsyncTaskParamsPtr
;
typedef
std
::
shared_ptr
<
ClientAsyncTaskParams
>
ClientAsyncTaskParamsPtr
;
static
const
char
*
const
NOT_MSGQ_CLIENT
=
"Not a MsgQueue Client"
;
static
const
char
*
const
NOT_MSGQ_CLIENT
=
"Not a MsgQueue Client"
;
static
const
char
*
const
NOT_PUBSUB_CLIENT
=
"Not a PubSub Client"
;
static
const
char
*
const
NOT_PUBSUB_CLIENT
=
"Not a PubSub Client"
;
...
...
src/common/Microservice_Iface.h
View file @
22805a1c
...
@@ -394,6 +394,20 @@ namespace nsMicroservice_Iface
...
@@ -394,6 +394,20 @@ namespace nsMicroservice_Iface
virtual
MSRetStat
Send
(
Microservice_MsgQContext
*
p_msgCtx
)
=
0
;
virtual
MSRetStat
Send
(
Microservice_MsgQContext
*
p_msgCtx
)
=
0
;
};
};
/**
* Channel used for full-duplex like web-socket
*/
struct
IChannelClient
:
public
IClient
{
using
OnMessageCallback
=
std
::
function
<
void
(
const
char
*
p_msg
,
int
len
)
>
;
using
OnErrorCallback
=
std
::
function
<
void
(
std
::
string
&
,
std
::
string
&
)
>
;
static
constexpr
const
char
*
TYPE
=
"Channel"
;
virtual
const
char
*
getType
()
final
{
return
TYPE
;
}
virtual
MSRetStat
InitRecv
(
OnMessageCallback
msgCllback
,
OnErrorCallback
errorCallback
)
=
0
;
virtual
MSRetStat
Send
(
const
char
*
p_msg
)
=
0
;
};
struct
IContext
struct
IContext
{
{
...
...
src/impl/Microservice_IMsgArchiverCerealImpls.h
View file @
22805a1c
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#define MICROSERVICE_MICRISERVICE_IMSGARCHIVERCEREALIMPLSL_H
#define MICROSERVICE_MICRISERVICE_IMSGARCHIVERCEREALIMPLSL_H
#include <common/Microservice_Iface.h>
#include <common/Microservice_Iface.h>
#include <cereal/archives/binary.hpp>
template
<
typename
Msg
>
template
<
typename
Msg
>
class
Microservice_IMsgArchiverCerealJson
:
public
nsMicroservice_Iface
::
IMsgArchiver
<
Msg
>
class
Microservice_IMsgArchiverCerealJson
:
public
nsMicroservice_Iface
::
IMsgArchiver
<
Msg
>
...
@@ -45,4 +46,42 @@ public:
...
@@ -45,4 +46,42 @@ public:
}
}
};
};
template
<
typename
Msg
>
class
Microservice_IMsgArchiverCerealBin
:
public
nsMicroservice_Iface
::
IMsgArchiver
<
Msg
>
{
public
:
virtual
MSRetStat
parse
(
std
::
string
&
inStr
,
Msg
&
outMsg
)
override
{
MSRetStat
retStat
;
try
{
std
::
stringstream
ss
;
ss
<<
inStr
;
{
cereal
::
BinaryInputArchive
binInputArchive
(
ss
);
binInputArchive
(
outMsg
);
}
}
catch
(
std
::
exception
exp
){
retStat
.
SetError
(
exp
.
what
());
}
return
retStat
;
}
virtual
MSRetStat
build
(
Msg
&
inMsg
,
std
::
string
&
outStr
)
override
{
MSRetStat
retStat
;
try
{
std
::
stringstream
ss
;
{
cereal
::
BinaryOutputArchive
jsonOutputArchive
(
ss
);
jsonOutputArchive
(
inMsg
);
}
// I like to move it move it....
outStr
=
std
::
move
(
ss
.
str
());
}
catch
(
std
::
exception
exp
){
retStat
.
SetError
(
exp
.
what
());
}
return
retStat
;
}
};
#endif //MICROSERVICE_MICRISERVICE_IMSGARCHIVERCEREALIMPLSL_H
#endif //MICROSERVICE_MICRISERVICE_IMSGARCHIVERCEREALIMPLSL_H
src/impl/clients/MSICommandClientHttpImpl.cpp
View file @
22805a1c
...
@@ -50,7 +50,7 @@ bool MSICommandClientHttpImpl::BuildUrl(MSCommandParams* p_cmd_params, std::stri
...
@@ -50,7 +50,7 @@ bool MSICommandClientHttpImpl::BuildUrl(MSCommandParams* p_cmd_params, std::stri
auto
entity
=
p_cmd_params
->
GetEntity
().
c_str
();
auto
entity
=
p_cmd_params
->
GetEntity
().
c_str
();
if
(
strncmp
(
entity
,
HTTP_SCHEME
,
HTTP_SCHEME_LEN
)
!=
0
)
if
(
strncmp
(
entity
,
HTTP_SCHEME
,
HTTP_SCHEME_LEN
)
!=
0
)
unencoded_url
.
append
(
HTTP_SCHEME
).
append
(
entity
);
unencoded_url
.
append
(
HTTP_SCHEME
)
;
//
.append(entity);
unencoded_url
.
append
(
entity
);
unencoded_url
.
append
(
entity
);
// params
// params
if
(
!
p_cmd_params
->
GetParams
().
empty
())
if
(
!
p_cmd_params
->
GetParams
().
empty
())
...
...
src/impl/servers/Microservice_IRestServerMongooseImpl.cpp
View file @
22805a1c
...
@@ -84,8 +84,8 @@ bool cMicroservice_IRestServerMongooseImpl::build(std::string& appName,
...
@@ -84,8 +84,8 @@ bool cMicroservice_IRestServerMongooseImpl::build(std::string& appName,
if
(
mpc_Param
->
getHost
().
compare
(
nsMicroservice_Constants
::
LOCALHOST
)
!=
0
)
if
(
mpc_Param
->
getHost
().
compare
(
nsMicroservice_Constants
::
LOCALHOST
)
!=
0
)
{
{
str_hostport
.
assign
(
mpc_Param
->
getHost
());
str_hostport
.
assign
(
mpc_Param
->
getHost
());
str_hostport
.
append
(
":"
);
}
}
str_hostport
.
append
(
":"
);
str_hostport
.
append
(
portStr
.
str
());
str_hostport
.
append
(
portStr
.
str
());
/*
/*
* creating the server manager object
* creating the server manager object
...
...
test/Microservice_ZMQTest.cpp
View file @
22805a1c
...
@@ -146,7 +146,7 @@ int main(int argc, char *argv[]) {
...
@@ -146,7 +146,7 @@ int main(int argc, char *argv[]) {
//test_pubsub(context);
//test_pubsub(context);
//test_Cereal();
//test_Cereal();
// test_msgQ(
);
test_msgQ
(
context
);
getchar
();
getchar
();
...
...
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