Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Redis Receiver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BIAS
Receivers
Redis Receiver
Commits
427023f5
Commit
427023f5
authored
1 year ago
by
Valerio Pastore
Browse files
Options
Downloads
Patches
Plain Diff
revert from stream to list
parent
91c14407
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
deps/Base-DAQ
+1
-1
1 addition, 1 deletion
deps/Base-DAQ
include/Redis_Receiver.h
+0
-1
0 additions, 1 deletion
include/Redis_Receiver.h
src/Redis_Receiver.cpp
+16
-28
16 additions, 28 deletions
src/Redis_Receiver.cpp
with
17 additions
and
30 deletions
Base-DAQ
@
98d5831a
Compare
4ab0a2d1
...
98d5831a
Subproject commit
4ab0a2d1455b3f285bba05e54c732772ad6852ac
Subproject commit
98d5831a3058e261def1b2c2df3f6bc848920eb9
This diff is collapsed.
Click to expand it.
include/Redis_Receiver.h
+
0
−
1
View file @
427023f5
...
...
@@ -24,7 +24,6 @@ protected:
int
port
;
void
split_ip_port
(
const
std
::
string
&
ip_port
,
std
::
string
&
ip
,
std
::
string
&
port
);
bool
checkRedisStream
(
redisReply
&
r
);
public
:
RedisReceiver
(
std
::
string
ip
,
int
prt
,
std
::
string
key
);
~
RedisReceiver
()
{
...
...
This diff is collapsed.
Click to expand it.
src/Redis_Receiver.cpp
+
16
−
28
View file @
427023f5
...
...
@@ -38,12 +38,11 @@ int RedisReceiver::connectToServer() { // no differences in implementation
return
connectToClient
();
}
int
RedisReceiver
::
closeConnectionToServer
(){
int
RedisReceiver
::
closeConnectionToServer
()
{
redisFree
(
context
);
return
1
;
}
int
RedisReceiver
::
closeConnectionToClient
(){
int
RedisReceiver
::
closeConnectionToClient
()
{
redisFree
(
context
);
return
1
;
}
...
...
@@ -62,39 +61,28 @@ bool RedisReceiver::isConnectedToServer() const {
* @return number of bytes received [-1 error, 0 done]
*/
int
RedisReceiver
::
receiveFromClient
(
PacketLib
::
BasePacket
&
pack
)
{
std
::
stringstream
cmd
;
cmd
<<
"XREAD BLOCK 0 STREAMS "
;
cmd
<<
key
;
cmd
<<
" $"
;
redisReply
*
r
=
(
redisReply
*
)
redisCommand
(
context
,
cmd
.
str
().
c_str
());
if
(
checkRedisStream
(
*
r
)){
redisReply
*
binaryValue
=
r
->
element
[
0
]
->
element
[
1
]
->
element
[
0
]
->
element
[
1
]
->
element
[
1
];
int
size
=
binaryValue
->
len
;
pack
.
copyToBinaryPointer
(
reinterpret_cast
<
uint8_t
*>
(
binaryValue
->
str
),
size
);
std
::
string
cmd
(
"RPOP "
);
cmd
.
append
(
key
);
redisReply
*
r
=
(
redisReply
*
)
redisCommand
(
context
,
cmd
.
c_str
());
if
(
r
->
type
==
REDIS_REPLY_STRING
&&
r
->
type
!=
REDIS_REPLY_NIL
)
{
int
size
=
r
->
len
;
pack
.
copyToBinaryPointer
(
reinterpret_cast
<
uint8_t
*>
(
r
->
str
),
size
);
freeReplyObject
(
r
);
return
size
;
}
std
::
cout
<<
"FAIL"
<<
std
::
endl
;
freeReplyObject
(
r
);
return
-
1
;
}
int
RedisReceiver
::
sendToServer
(
PacketLib
::
BasePacket
&
packet
)
{
uint
size
=
packet
.
getPacketStructureByteSize
();
redisReply
*
r
=
(
redisReply
*
)
redisCommand
(
context
,
"XADD %s * data %b"
,
key
,
packet
.
getBinaryPointer
(),
size
);
if
(
r
==
nullptr
||
r
->
type
==
REDIS_REPLY_ERROR
)
{
std
::
cerr
<<
"XADD command failed: "
<<
r
->
str
<<
std
::
endl
;
return
-
1
;
}
uint
size
=
packet
.
getHeaderSize
()
+
packet
.
getPayloadSize
()
+
packet
.
getTailSize
();
redisReply
*
r
=
(
redisReply
*
)
redisCommand
(
context
,
"LPUSH %s %b"
,
key
,
packet
.
getBinaryPointer
(),
size
);
if
(
r
==
nullptr
||
r
->
type
==
REDIS_REPLY_ERROR
)
{
std
::
cerr
<<
"LPUSH command failed: "
<<
r
->
str
<<
std
::
endl
;
return
-
1
;
}
return
size
;
return
0
;
}
bool
RedisReceiver
::
checkRedisStream
(
redisReply
&
r
)
{
if
(
r
.
type
==
REDIS_REPLY_ARRAY
&&
r
.
element
[
0
]
!=
NULL
)
return
true
;
return
false
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment