mirror of
https://github.com/netdata/netdata.git
synced 2025-04-14 17:48:37 +00:00

This PR merges the feature-branch to make the cloud live. It contains the following work: Co-authored-by: Andrew Moss <1043609+amoss@users.noreply.github.com(opens in new tab)> Co-authored-by: Jacek Kolasa <jacek.kolasa@gmail.com(opens in new tab)> Co-authored-by: Austin S. Hemmelgarn <austin@netdata.cloud(opens in new tab)> Co-authored-by: James Mills <prologic@shortcircuit.net.au(opens in new tab)> Co-authored-by: Markos Fountoulakis <44345837+mfundul@users.noreply.github.com(opens in new tab)> Co-authored-by: Timotej S <6674623+underhood@users.noreply.github.com(opens in new tab)> Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com(opens in new tab)> * dashboard with new navbars, v1.0-alpha.9: PR #8478 * dashboard v1.0.11: netdata/dashboard#76 Co-authored-by: Jacek Kolasa <jacek.kolasa@gmail.com(opens in new tab)> * Added installer code to bundle JSON-c if it's not present. PR #8836 Co-authored-by: James Mills <prologic@shortcircuit.net.au(opens in new tab)> * Fix claiming config PR #8843 * Adds JSON-c as hard dep. for ACLK PR #8838 * Fix SSL renegotiation errors in old versions of openssl. PR #8840. Also - we have a transient problem with opensuse CI so this PR disables them with a commit from @prologic. Co-authored-by: James Mills <prologic@shortcircuit.net.au(opens in new tab)> * Fix claiming error handling PR #8850 * Added CI to verify JSON-C bundling code in installer PR #8853 * Make cloud-enabled flag in web/api/v1/info be independent of ACLK build success PR #8866 * Reduce ACLK_STABLE_TIMEOUT from 10 to 3 seconds PR #8871 * remove old-cloud related UI from old dashboard (accessible now via /old suffix) PR #8858 * dashboard v1.0.13 PR #8870 * dashboard v1.0.14 PR #8904 * Provide feedback on proxy setting changes PR #8895 * Change the name of the connect message to update during an ongoing session PR #8927 * Fetch active alarms from alarm_log PR #8944
92 lines
2.4 KiB
C
92 lines
2.4 KiB
C
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#ifndef ACLK_LWS_WSS_CLIENT_H
|
|
#define ACLK_LWS_WSS_CLIENT_H
|
|
|
|
#include <libwebsockets.h>
|
|
|
|
#include "libnetdata/libnetdata.h"
|
|
|
|
// This is as define because ideally the ACLK at high level
|
|
// can do mosqitto writes and reads only from one thread
|
|
// which is cleaner implementation IMHO
|
|
// in such case this mutexes are not necessarry and life
|
|
// is simpler
|
|
#define ACLK_LWS_MOSQUITTO_IO_CALLS_MULTITHREADED 1
|
|
|
|
#define ACLK_LWS_WSS_RECV_BUFF_SIZE_BYTES (128 * 1024)
|
|
|
|
#define ACLK_LWS_CALLBACK_HISTORY 10
|
|
|
|
#ifdef ACLK_LWS_MOSQUITTO_IO_CALLS_MULTITHREADED
|
|
#define aclk_lws_mutex_init(x) netdata_mutex_init(x)
|
|
#define aclk_lws_mutex_lock(x) netdata_mutex_lock(x)
|
|
#define aclk_lws_mutex_unlock(x) netdata_mutex_unlock(x)
|
|
#else
|
|
#define aclk_lws_mutex_init(x)
|
|
#define aclk_lws_mutex_lock(x)
|
|
#define aclk_lws_mutex_unlock(x)
|
|
#endif
|
|
|
|
struct aclk_lws_wss_engine_callbacks {
|
|
void (*connection_established_callback)();
|
|
void (*data_rcvd_callback)();
|
|
void (*data_writable_callback)();
|
|
void (*connection_closed)();
|
|
};
|
|
|
|
struct lws_wss_packet_buffer {
|
|
unsigned char *data;
|
|
size_t data_size, written;
|
|
struct lws_wss_packet_buffer *next;
|
|
};
|
|
|
|
struct aclk_lws_wss_engine_instance {
|
|
//target host/port for connection
|
|
char *host;
|
|
int port;
|
|
|
|
//internal data
|
|
struct lws_context *lws_context;
|
|
struct lws *lws_wsi;
|
|
|
|
#ifdef ACLK_LWS_MOSQUITTO_IO_CALLS_MULTITHREADED
|
|
netdata_mutex_t write_buf_mutex;
|
|
netdata_mutex_t read_buf_mutex;
|
|
#endif
|
|
|
|
struct lws_wss_packet_buffer *write_buffer_head;
|
|
struct lws_ring *read_ringbuffer;
|
|
|
|
//flags to be readed by engine user
|
|
int websocket_connection_up;
|
|
|
|
// currently this is by default disabled
|
|
|
|
int data_to_read;
|
|
int upstream_reconnect_request;
|
|
|
|
int lws_callback_history[ACLK_LWS_CALLBACK_HISTORY];
|
|
};
|
|
|
|
void aclk_lws_wss_client_destroy();
|
|
void aclk_lws_wss_destroy_context();
|
|
|
|
int aclk_lws_wss_connect(char *host, int port);
|
|
|
|
int aclk_lws_wss_client_write(void *buf, size_t count);
|
|
int aclk_lws_wss_client_read(void *buf, size_t count);
|
|
void aclk_lws_wss_service_loop();
|
|
|
|
void aclk_lws_wss_mqtt_layer_disconect_notif();
|
|
|
|
// Notifications inside the layer above
|
|
void aclk_lws_connection_established();
|
|
void aclk_lws_connection_data_received();
|
|
void aclk_lws_connection_closed();
|
|
void lws_wss_check_queues(size_t *write_len, size_t *write_len_bytes, size_t *read_len);
|
|
|
|
void aclk_wss_set_proxy(struct lws_vhost *vhost);
|
|
|
|
#define FRAGMENT_SIZE 4096
|
|
#endif
|