Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consumer should populate table, not producer #7

Merged
merged 2 commits into from
Apr 19, 2016
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
25 changes: 25 additions & 0 deletions common/consumertable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,31 @@ void ConsumerTable::pop(KeyOpFieldsValuesTuple &kco)
JSon::readJson(pop_front(m_results), fieldsValues);

kco = std::make_tuple(key, op, fieldsValues);

// NOTE: not entire pop operation is atomic
// since we first get values from the queue
// and then put them into table, but that
// is fine since we are the only consumer
// of this data

multi();

if (op == DEL_COMMAND)
{

std::string del("DEL ");
del += getKeyName(key);

enqueue(del, REDIS_REPLY_INTEGER);
}
else
{
for (FieldValueTuple &i : fieldsValues)
enqueue(formatHSET(getKeyName(key), fvField(i), fvValue(i)),
REDIS_REPLY_INTEGER, true);
}

exec();
}

void ConsumerTable::addFd(fd_set *fd)
Expand Down
4 changes: 0 additions & 4 deletions common/producertable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ void ProducerTable::enqueueDbChange(string key, string value, string op)
void ProducerTable::set(string key, vector<FieldValueTuple> &values, string op)
{
multi();
for (FieldValueTuple &i : values)
enqueue(formatHSET(getKeyName(key), fvField(i), fvValue(i)),
REDIS_REPLY_INTEGER, true);

enqueueDbChange(key, JSon::buildJson(values), op);
exec();
Expand All @@ -61,7 +58,6 @@ void ProducerTable::del(string key, string op)
multi();

enqueueDbChange(key, "{}", op);
enqueue(del, REDIS_REPLY_INTEGER);

exec();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ tests_SOURCES = redis_ut.cpp

tests_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST)
tests_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST)
tests_LDADD = -lnl-genl-3 -lhiredis -lhiredis -lpthread \
-L$(top_srcdir)/common -lswsscommon $(LDADD_GTEST)
tests_LDADD = $(LDADD_GTEST) -lnl-genl-3 -lhiredis -lhiredis -lpthread \
-L$(top_srcdir)/common -lswsscommon