Add a minimum status gap to avoid thin peroids in the case of multiple services updating their status after another
This commit is contained in:
@@ -195,7 +195,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
if (report_queued > 0) {
|
||||
report_queued = 0;
|
||||
report();
|
||||
report(1);
|
||||
}
|
||||
if (last_doc_generated <= now - web_refresh) {
|
||||
index_doc = generate_index();
|
||||
|
||||
@@ -268,7 +268,7 @@ uint8_t add_endpoint(struct Service* self, const char* uri) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void report() {
|
||||
void report(int min_gap) {
|
||||
if (status_timeline.size + 1 >= status_timeline.capacity)
|
||||
vector_pop_front(&status_timeline); // remove (what should be) oldest entry
|
||||
|
||||
@@ -284,6 +284,7 @@ void report() {
|
||||
vector_push_back(&peroid->server_statuses, &server_status);
|
||||
}
|
||||
|
||||
if (status_timeline.size > 0 && (*((struct StatusPeroid**)vector_back(&status_timeline)))->time >= queued_time - (min_gap * 1000000)) return;
|
||||
vector_push_back(&status_timeline, &peroid);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ struct EndpointStatus;
|
||||
struct Endpoint;
|
||||
struct Service;
|
||||
|
||||
void report();
|
||||
void* run_endpoint(void* endpoint);
|
||||
void queue_report(struct EndpointStatus status);
|
||||
void load_service(struct Service** self);
|
||||
uint8_t add_endpoint(struct Service* self, const char* uri);
|
||||
enum State get_state(struct Service** self);
|
||||
void report(int min_gap);
|
||||
struct ServerStatus* update_server_status(struct Service** self);
|
||||
void deinit_service(struct Service** self);
|
||||
const char* state_text(enum State state);
|
||||
|
||||
Reference in New Issue
Block a user