master
h 52 lines 1.83 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #ifndef NETDATA_STREAM_PARENTS_H
4 #define NETDATA_STREAM_PARENTS_H
5
6 #include "libnetdata/libnetdata.h"
7
8 struct rrdhost;
9 struct rrdhost_status_t;
10 struct stream_parent;
11 typedef struct stream_parent STREAM_PARENT;
12
13 typedef struct rrdhost_stream_parents {
14 RW_SPINLOCK spinlock;
15 STREAM_PARENT *all; // a linked list of possible destinations
16 STREAM_PARENT *current; // the current destination from the above list
17 } RRDHOST_STREAM_PARENTS;
18
19 #include "stream-handshake.h"
20 #include "database/rrdhost.h"
21
22 void rrdhost_stream_parent_ssl_init(struct sender_state *s);
23
24 int stream_info_to_json_v1(BUFFER *wb, const char *machine_guid);
25
26 bool stream_parent_connect_to_one(
27 ND_SOCK *sender_sock,
28 struct rrdhost *host,
29 int default_port,
30 time_t timeout,
31 char *connected_to,
32 size_t connected_to_size,
33 STREAM_PARENT **destination);
34
35 void rrdhost_stream_parents_to_json(BUFFER *wb, struct rrdhost_status_t *s);
36 STREAM_HANDSHAKE stream_parent_get_disconnect_reason(STREAM_PARENT *d);
37 void stream_parent_set_host_disconnect_reason(RRDHOST *host, STREAM_HANDSHAKE reason, time_t since);
38 void stream_parent_set_host_reconnect_delay(RRDHOST *host, STREAM_HANDSHAKE reason, time_t secs);
39 void stream_parent_set_host_connect_failure_reason(RRDHOST *host, STREAM_HANDSHAKE reason, time_t secs);
40 usec_t stream_parent_get_reconnection_ut(STREAM_PARENT *d);
41 bool stream_parent_is_ssl(STREAM_PARENT *d);
42
43 usec_t stream_parent_handshake_error_to_json(BUFFER *wb, struct rrdhost *host);
44
45 void stream_parents_host_reset(RRDHOST *host, STREAM_HANDSHAKE reason);
46
47 void rrdhost_stream_parents_update_from_destination(struct rrdhost *host);
48 void rrdhost_stream_parents_free(struct rrdhost *host, bool having_write_lock);
49
50 void rrdhost_stream_parents_init(struct rrdhost *host);
51
52 #endif //NETDATA_STREAM_PARENTS_H