]> arthur.barton.de Git - netdata.git/blob - src/registry_person.h
dns_query_time plugin: replace "." with "_" in dimensions
[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     avl avl;                    // binary tree node
12
13     REGISTRY_URL *url;          // de-duplicated URL
14     REGISTRY_MACHINE *machine;  // link the MACHINE of this URL
15
16     uint8_t flags;
17
18     uint32_t first_t;           // the first time we saw this
19     uint32_t last_t;            // the last time we saw this
20     uint32_t usages;            // how many times this has been accessed
21
22     char machine_name[1];       // the name of the machine, as known by the user
23     // dynamically allocated to fit properly
24 };
25 typedef struct registry_person_url REGISTRY_PERSON_URL;
26
27 // A person
28 struct registry_person {
29     char guid[GUID_LEN + 1];    // the person GUID
30
31     avl_tree person_urls;       // dictionary of PERSON_URLs
32
33     uint32_t first_t;           // the first time we saw this
34     uint32_t last_t;            // the last time we saw this
35     uint32_t usages;            // how many times this has been accessed
36
37     //uint32_t flags;
38     //char *email;
39 };
40 typedef struct registry_person REGISTRY_PERSON;
41
42 // PERSON_URL
43 extern REGISTRY_PERSON_URL *registry_person_url_index_find(REGISTRY_PERSON *p, const char *url);
44 extern REGISTRY_PERSON_URL *registry_person_url_index_add(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) NEVERNULL WARNUNUSED;
45 extern REGISTRY_PERSON_URL *registry_person_url_index_del(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu) WARNUNUSED;
46
47 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);
48 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);
49
50 // PERSON
51 extern REGISTRY_PERSON *registry_person_find(const char *person_guid);
52 extern REGISTRY_PERSON *registry_person_allocate(const char *person_guid, time_t when);
53 extern REGISTRY_PERSON *registry_person_get(const char *person_guid, time_t when);
54 extern void registry_person_del(REGISTRY_PERSON *p);
55
56 // LINKING PERSON -> PERSON_URL
57 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);
58 extern void registry_person_unlink_from_url(REGISTRY_PERSON *p, REGISTRY_PERSON_URL *pu);
59
60 #endif //NETDATA_REGISTRY_PERSON_H