Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions common/notificationconsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ swss::NotificationConsumer::NotificationConsumer(swss::DBConnector *db, const st
m_db(db),
m_subscribe(NULL),
m_channel(channel)
{
init();
}

swss::NotificationConsumer::NotificationConsumer(std::shared_ptr<swss::DBConnector> db, const std::string &channel, int pri, size_t popBatchSize):
Selectable(pri),
POP_BATCH_SIZE(popBatchSize),
m_db_shrd(db),
m_db(m_db_shrd.get()),
m_subscribe(NULL),
m_channel(channel)
{
init();
}

void swss::NotificationConsumer::init()
{
SWSS_LOG_ENTER();

Expand Down
4 changes: 4 additions & 0 deletions common/notificationconsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include <vector>
#include <queue>
#include <memory>

#include <hiredis/hiredis.h>

Expand All @@ -22,6 +23,7 @@ class NotificationConsumer : public Selectable
{
public:
NotificationConsumer(swss::DBConnector *db, const std::string &channel, int pri = 100, size_t popBatchSize = DEFAULT_NC_POP_BATCH_SIZE);
NotificationConsumer(std::shared_ptr<swss::DBConnector> db, const std::string &channel, int pri = 100, size_t popBatchSize = DEFAULT_NC_POP_BATCH_SIZE);

// Pop one or multiple data from the internal queue which fed from redis socket
// Note:
Expand Down Expand Up @@ -49,9 +51,11 @@ class NotificationConsumer : public Selectable
NotificationConsumer(const NotificationConsumer &other);
NotificationConsumer& operator = (const NotificationConsumer &other);

void init();
void processReply(redisReply *reply);
void subscribe();

std::shared_ptr<swss::DBConnector> m_db_shrd;
swss::DBConnector *m_db;
swss::DBConnector *m_subscribe;
std::string m_channel;
Expand Down