-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponsePublisher] add pipeline support (#2511)
* [ResponsePublisher] add pipeline support Why I did it I did it to improve performance when sending many responses. Responses are buffered in redis client before beeing sent out to redis server, while orchagent has no more pending tasks to do, responses are flushed to redis.
- Loading branch information
1 parent
44ea6a0
commit 4df5cab
Showing
9 changed files
with
117 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/mock_tests/response_publisher/response_publisher_ut.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "response_publisher.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
bool gResponsePublisherRecord{false}; | ||
bool gResponsePublisherLogRotate{false}; | ||
std::ofstream gResponsePublisherRecordOfs; | ||
std::string gResponsePublisherRecordFile; | ||
|
||
using namespace swss; | ||
|
||
TEST(ResponsePublisher, TestPublish) | ||
{ | ||
DBConnector conn{"APPL_STATE_DB", 0}; | ||
Table stateTable{&conn, "SOME_TABLE"}; | ||
std::string value; | ||
ResponsePublisher publisher{}; | ||
|
||
publisher.publish("SOME_TABLE", "SOME_KEY", {{"field", "value"}}, ReturnCode(SAI_STATUS_SUCCESS)); | ||
ASSERT_TRUE(stateTable.hget("SOME_KEY", "field", value)); | ||
ASSERT_EQ(value, "value"); | ||
} | ||
|
||
TEST(ResponsePublisher, TestPublishBuffered) | ||
{ | ||
DBConnector conn{"APPL_STATE_DB", 0}; | ||
Table stateTable{&conn, "SOME_TABLE"}; | ||
std::string value; | ||
ResponsePublisher publisher{}; | ||
|
||
publisher.setBuffered(true); | ||
|
||
publisher.publish("SOME_TABLE", "SOME_KEY", {{"field", "value"}}, ReturnCode(SAI_STATUS_SUCCESS)); | ||
publisher.flush(); | ||
ASSERT_TRUE(stateTable.hget("SOME_KEY", "field", value)); | ||
ASSERT_EQ(value, "value"); | ||
} |