| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_REGISTRY_PERSON_H |
| 4 | #define NETDATA_REGISTRY_PERSON_H 1 |
| 5 | |
| 6 | #include "registry_internals.h" |
| 7 | |
| 8 | // ---------------------------------------------------------------------------- |
| 9 | // PERSON structures |
| 10 | |
| 11 | // for each PERSON-URL pair we keep this |
| 12 | struct registry_person_url { |
| 13 | uint8_t flags; |
| 14 | |
| 15 | uint32_t usages; // how many times this has been accessed |
| 16 | |
| 17 | uint32_t first_t; // the first time we saw this |
| 18 | uint32_t last_t; // the last time we saw this |
| 19 | |
| 20 | REGISTRY_MACHINE *machine; // link the MACHINE of this URL |
| 21 | STRING *machine_name; // the hostname of the machine |
| 22 | STRING *url; // de-duplicated URL |
| 23 | |
| 24 | struct registry_person_url *prev, *next; |
| 25 | }; |
| 26 | typedef struct registry_person_url REGISTRY_PERSON_URL; |
| 27 | |
| 28 | // A person |
| 29 | struct registry_person { |
| 30 | char guid[GUID_LEN + 1]; // the person GUID |
| 31 | |
| 32 | REGISTRY_PERSON_URL *person_urls; // dictionary of PERSON_URLs |
| 33 | |
| 34 | uint32_t first_t; // the first time we saw this |
| 35 | uint32_t last_t; // the last time we saw this |
| 36 | uint32_t usages; // how many times this has been accessed |
| 37 | }; |
| 38 | typedef struct registry_person REGISTRY_PERSON; |
| 39 | |
| 40 | // PERSON_URL |
| 41 | REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, STRING *url); |
| 42 | REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) NEVERNULL WARNUNUSED; |
| 43 | REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) WARNUNUSED; |
| 44 | |
| 45 | REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when); |
| 46 | REGISTRY_PERSON_URL *registry_person_url_reallocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when, REGISTRY_PERSON_URL *pu); |
| 47 | |
| 48 | // PERSON |
| 49 | REGISTRY_PERSON *registry_person_find(const char *person_guid); |
| 50 | REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when); |
| 51 | REGISTRY_PERSON *registry_person_find_or_create(const char *person_guid, time_t when, bool is_dummy); |
| 52 | |
| 53 | // LINKING PERSON -> PERSON_URL |
| 54 | REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, STRING *url, char *machine_name, size_t machine_name_len, time_t when); |
| 55 | void registry_person_unlink_from_url(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu); |
| 56 | |
| 57 | #endif //NETDATA_REGISTRY_PERSON_H |