]> arthur.barton.de Git - netdata.git/blob - src/registry_person.h
removed over-optimization at the registry to simplify its logic and remove race condi...
[netdata.git] / src / registry_person.h
1 #ifndef NETDATA_REGISTRY_PERSON_H
2 #define NETDATA_REGISTRY_PERSON_H
3
4 #include "registry_internals.h"
5
6 // ----------------------------------------------------------------------------
7 // PERSON structures
8
9 // for each PERSON-URL pair we keep this
10 struct registry_person_url {
11     REGISTRY_URL *url;          // de-duplicated URL
12     REGISTRY_MACHINE *machine;  // link the MACHINE of this URL
13
14     uint8_t flags;
15
16     uint32_t first_t;           // the first time we saw this
17     uint32_t last_t;            // the last time we saw this
18     uint32_t usages;            // how many times this has been accessed
19
20     char machine_name[1];       // the name of the machine, as known by the user
21     // dynamically allocated to fit properly
22 };
23 typedef struct registry_person_url REGISTRY_PERSON_URL;
24
25 // A person
26 struct registry_person {
27     char guid[GUID_LEN + 1];    // the person GUID
28
29     DICTIONARY *person_urls;    // dictionary of PERSON_URL *
30
31     uint32_t first_t;           // the first time we saw this
32     uint32_t last_t;            // the last time we saw this
33     uint32_t usages;            // how many times this has been accessed
34 };
35 typedef struct registry_person REGISTRY_PERSON;
36
37 extern REGISTRY_PERSON *registry_person_find(const char *person_guid);
38 extern REGISTRY_PERSON_URL *registry_person_url_allocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when);
39 extern REGISTRY_PERSON_URL *registry_person_url_reallocate(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when, REGISTRY_PERSON_URL *pu);
40 extern REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when);
41 extern REGISTRY_PERSON *registry_person_get(const char *person_guid, time_t when);
42 extern REGISTRY_PERSON_URL *registry_person_link_to_url(REGISTRY_PERSON *p, REGISTRY_MACHINE *m, REGISTRY_URL *u, char *name, size_t namelen, time_t when);
43
44 #endif //NETDATA_REGISTRY_PERSON_H