fix(driver): cannot be uploaded in time when values have not changed

This commit is contained in:
fengzero
2023-07-24 07:39:54 +00:00
parent 9c81e79992
commit 7c52356d30
3 changed files with 23 additions and 6 deletions
+14 -3
View File
@@ -123,9 +123,10 @@ void neu_driver_cache_add(neu_driver_cache_t *cache, const char *group,
nng_mtx_unlock(cache->mtx);
}
void neu_driver_cache_update(neu_driver_cache_t *cache, const char *group,
const char *tag, int64_t timestamp,
neu_dvalue_t value)
void neu_driver_cache_update_change(neu_driver_cache_t *cache,
const char *group, const char *tag,
int64_t timestamp, neu_dvalue_t value,
bool change)
{
struct elem *elem = NULL;
tkey_t key = to_key(group, tag);
@@ -185,6 +186,9 @@ void neu_driver_cache_update(neu_driver_cache_t *cache, const char *group,
}
}
if (change) {
elem->changed = true;
}
elem->value.type = value.type;
elem->value.value = value.value;
}
@@ -192,6 +196,13 @@ void neu_driver_cache_update(neu_driver_cache_t *cache, const char *group,
nng_mtx_unlock(cache->mtx);
}
void neu_driver_cache_update(neu_driver_cache_t *cache, const char *group,
const char *tag, int64_t timestamp,
neu_dvalue_t value)
{
neu_driver_cache_update_change(cache, group, tag, timestamp, value, false);
}
int neu_driver_cache_get(neu_driver_cache_t *cache, const char *group,
const char *tag, neu_driver_cache_value_t *value)
{
+4
View File
@@ -34,6 +34,10 @@ void neu_driver_cache_add(neu_driver_cache_t *cache, const char *group,
void neu_driver_cache_update(neu_driver_cache_t *cache, const char *group,
const char *tag, int64_t timestamp,
neu_dvalue_t value);
void neu_driver_cache_update_change(neu_driver_cache_t *cache,
const char *group, const char *tag,
int64_t timestamp, neu_dvalue_t value,
bool change);
void neu_driver_cache_del(neu_driver_cache_t *cache, const char *group,
const char *tag);
+5 -3
View File
@@ -107,12 +107,14 @@ static void update_im(neu_adapter_t *adapter, const char *group,
neu_reqresp_head_t header = { 0 };
if (tag == NULL || value.type == NEU_TYPE_ERROR) {
nlog_warn("update_im tag is null or value is error");
nlog_warn("update_im tag is null or value is error %d",
value.value.i32);
return;
}
UT_array *tags = neu_adapter_driver_get_ptag(driver, group, tag);
neu_driver_cache_update(driver->cache, group, tag, global_timestamp, value);
neu_driver_cache_update_change(driver->cache, group, tag, global_timestamp,
value, true);
driver->adapter.cb_funs.update_metric(&driver->adapter,
NEU_METRIC_TAG_READS_TOTAL, 1, NULL);
neu_datatag_t *first = utarray_front(tags);
@@ -1027,7 +1029,7 @@ UT_array *neu_adapter_driver_get_ptag(neu_adapter_driver_t *driver,
neu_datatag_t *t = neu_group_find_tag(find->group, tag);
if (t != NULL) {
utarray_new(tags, neu_tag_get_icd());
utarray_push_back(tags, &t);
utarray_push_back(tags, t);
neu_tag_free(t);
}
}