summaryrefslogtreecommitdiffstats
path: root/aclk/legacy/aclk_common.h
blob: 080680ff11dab614098c603d54dad6716b9f64bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef ACLK_COMMON_H
#define ACLK_COMMON_H

#include "../aclk_rrdhost_state.h"
#include "daemon/common.h"

extern netdata_mutex_t legacy_aclk_shared_state_mutex;
#define legacy_aclk_shared_state_LOCK netdata_mutex_lock(&legacy_aclk_shared_state_mutex)
#define legacy_aclk_shared_state_UNLOCK netdata_mutex_unlock(&legacy_aclk_shared_state_mutex)

// minimum and maximum supported version of ACLK
// in this version of agent
#define ACLK_VERSION_MIN 2
#define ACLK_VERSION_MAX 3

// Version negotiation messages have they own versioning
// this is also used for LWT message as we set that up
// before version negotiation
#define ACLK_VERSION_NEG_VERSION 1

// Maximum time to wait for version negotiation before aborting
// and defaulting to oldest supported version
#define VERSION_NEG_TIMEOUT 3

#if ACLK_VERSION_MIN > ACLK_VERSION_MAX
#error "ACLK_VERSION_MAX must be >= than ACLK_VERSION_MIN"
#endif

// Define ACLK Feature Version Boundaries Here
#define ACLK_V_COMPRESSION   2
#define ACLK_V_CHILDRENSTATE 3

#define ACLK_IS_HOST_INITIALIZING(host) (host->aclk_state.state == ACLK_HOST_INITIALIZING)
#define ACLK_IS_HOST_POPCORNING(host) (ACLK_IS_HOST_INITIALIZING(host) && host->aclk_state.t_last_popcorn_update)

extern struct legacy_aclk_shared_state {
    // optimization to avoid looping through hosts
    // every time Query Thread wakes up
    RRDHOST *next_popcorn_host;

    // read only while ACLK connected
    // protect by lock otherwise
    int version_neg;
    usec_t version_neg_wait_till;
} legacy_aclk_shared_state;

const char *aclk_proxy_type_to_s(ACLK_PROXY_TYPE *type);

int aclk_decode_base_url(char *url, char **aclk_hostname, int *aclk_port);

#endif //ACLK_COMMON_H