aclk_query_queue.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_ACLK_QUERY_QUEUE_H
  3. #define NETDATA_ACLK_QUERY_QUEUE_H
  4. #include "libnetdata/libnetdata.h"
  5. #include "../daemon/common.h"
  6. typedef enum {
  7. UNKNOWN,
  8. METADATA_INFO,
  9. METADATA_ALARMS,
  10. HTTP_API_V2,
  11. CHART_NEW,
  12. CHART_DEL,
  13. ALARM_STATE_UPDATE
  14. } aclk_query_type_t;
  15. struct aclk_query_metadata {
  16. RRDHOST *host;
  17. int initial_on_connect;
  18. };
  19. struct aclk_query_chart_add_del {
  20. RRDHOST *host;
  21. char* chart_name;
  22. };
  23. struct aclk_query_http_api_v2 {
  24. char *payload;
  25. char *query;
  26. };
  27. typedef struct aclk_query *aclk_query_t;
  28. struct aclk_query {
  29. aclk_query_type_t type;
  30. // dedup_id is used to deduplicate queries in the list
  31. // if type and dedup_id is the same message is deduplicated
  32. // set dedup_id to NULL to never deduplicate the message
  33. // set dedup_id to constant (e.g. empty string "") to make
  34. // message of this type ever exist only once in the list
  35. char *dedup_id;
  36. char *callback_topic;
  37. char *msg_id;
  38. usec_t created;
  39. aclk_query_t next;
  40. // TODO maybe remove?
  41. int version;
  42. union {
  43. struct aclk_query_metadata metadata_info;
  44. struct aclk_query_metadata metadata_alarms;
  45. struct aclk_query_http_api_v2 http_api_v2;
  46. struct aclk_query_chart_add_del chart_add_del;
  47. json_object *alarm_update;
  48. } data;
  49. };
  50. aclk_query_t aclk_query_new(aclk_query_type_t type);
  51. void aclk_query_free(aclk_query_t query);
  52. int aclk_queue_query(aclk_query_t query);
  53. aclk_query_t aclk_queue_pop(void);
  54. void aclk_queue_flush(void);
  55. void aclk_queue_lock(void);
  56. #endif /* NETDATA_ACLK_QUERY_QUEUE_H */