Broker Store updates: get a bit more infrastructure in place.

This compiles, but besides giving debug messages (and partially
performing inserts/updates) it is not really helpful and definitely WIP.

This also shows that I might have to re-think the approach that we will
take here. So far, we actually insert tables as tables into
Brokerstores. This opens up the potential to just have several tables
synchronized via a single brokerstore.

However, it turns out, that the current store_event API sends the
complete table with each update. Which is problematic for obvious
reasons - and not really sustainable.
This commit is contained in:
Johanna Amann 2020-05-29 14:32:16 -07:00
parent 8db83a5ed2
commit 558e89b3ba
5 changed files with 164 additions and 26 deletions

View file

@ -2079,14 +2079,27 @@ void TableVal::SendToStore(const Val* index, const Val* new_value, OnChangeType
if ( ! handle )
return;
if ( index->AsListVal()->Length() != 1 )
// we wither get passed the raw index_val - or a ListVal with exactly one element.
// Since broker does not support ListVals, we have to unoll this in the second case.
const Val* index_val;
if ( index->Type()->Tag() == TYPE_LIST )
{
builtin_error("table with complex index not supported for &broker_store");
return;
if ( index->AsListVal()->Length() != 1 )
{
builtin_error("table with complex index not supported for &broker_store");
return;
}
index_val = index->AsListVal()->Index(0);
}
else
{
index_val = index;
}
const auto index_val = index->AsListVal()->Index(0);
auto key_val = new StringVal("test");
// FIXME: at the moment this is hardcoded to the name of the broker store. I needed something to be able to tell
// me which store a change came from - and this still seems to be missing from the store_events. (Or I am blind).
auto key_val = new StringVal(broker_store);
auto broker_key = bro_broker::val_to_data(key_val);
auto broker_index = bro_broker::val_to_data(index_val);
Unref(key_val);