summaryrefslogtreecommitdiffstats
path: root/database/rrdfunctions.h
diff options
context:
space:
mode:
Diffstat (limited to 'database/rrdfunctions.h')
-rw-r--r--database/rrdfunctions.h43
1 files changed, 30 insertions, 13 deletions
diff --git a/database/rrdfunctions.h b/database/rrdfunctions.h
index 71ad96507..96aa3965e 100644
--- a/database/rrdfunctions.h
+++ b/database/rrdfunctions.h
@@ -1,26 +1,41 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef NETDATA_RRDFUNCTIONS_H
#define NETDATA_RRDFUNCTIONS_H 1
+// ----------------------------------------------------------------------------
+
#include "rrd.h"
-void rrdfunctions_init(RRDHOST *host);
-void rrdfunctions_destroy(RRDHOST *host);
+#define RRDFUNCTIONS_TIMEOUT_EXTENSION_UT (1 * USEC_PER_SEC)
-void rrd_collector_started(void);
-void rrd_collector_finished(void);
+typedef void (*rrd_function_result_callback_t)(BUFFER *wb, int code, void *result_cb_data);
+typedef bool (*rrd_function_is_cancelled_cb_t)(void *is_cancelled_cb_data);
+typedef void (*rrd_function_canceller_cb_t)(void *data);
+typedef void (*rrd_function_register_canceller_cb_t)(void *register_cancel_cb_data, rrd_function_canceller_cb_t cancel_cb, void *cancel_cb_data);
+typedef int (*rrd_function_execute_cb_t)(BUFFER *wb, int timeout, const char *function, void *collector_data,
+ rrd_function_result_callback_t result_cb, void *result_cb_data,
+ rrd_function_is_cancelled_cb_t is_cancelled_cb, void *is_cancelled_cb_data,
+ rrd_function_register_canceller_cb_t register_cancel_cb, void *register_cancel_db_data);
-typedef void (*function_data_ready_callback)(BUFFER *wb, int code, void *callback_data);
+void rrd_functions_inflight_init(void);
+void rrdfunctions_host_init(RRDHOST *host);
+void rrdfunctions_host_destroy(RRDHOST *host);
-typedef int (*function_execute_at_collector)(BUFFER *wb, int timeout, const char *function, void *collector_data,
- function_data_ready_callback callback, void *callback_data);
+void rrd_collector_started(void);
+void rrd_collector_finished(void);
-void rrd_collector_add_function(RRDHOST *host, RRDSET *st, const char *name, int timeout, const char *help,
- bool sync, function_execute_at_collector function, void *collector_data);
+// add a function, to be run from the collector
+void rrd_function_add(RRDHOST *host, RRDSET *st, const char *name, int timeout, const char *help,
+ bool sync, rrd_function_execute_cb_t execute_cb, void *execute_cb_data);
-int rrd_call_function_and_wait(RRDHOST *host, BUFFER *wb, int timeout, const char *name);
+// call a function, to be run from anywhere
+int rrd_function_run(RRDHOST *host, BUFFER *result_wb, int timeout, const char *cmd,
+ bool wait, const char *transaction,
+ rrd_function_result_callback_t result_cb, void *result_cb_data,
+ rrd_function_is_cancelled_cb_t is_cancelled_cb, void *is_cancelled_cb_data, const char *payload);
-typedef void (*rrd_call_function_async_callback)(BUFFER *wb, int code, void *callback_data);
-int rrd_call_function_async(RRDHOST *host, BUFFER *wb, int timeout, const char *name, rrd_call_function_async_callback, void *callback_data);
+// cancel a running function, to be run from anywhere
+void rrd_function_cancel(const char *transaction);
void rrd_functions_expose_rrdpush(RRDSET *st, BUFFER *wb);
void rrd_functions_expose_global_rrdpush(RRDHOST *host, BUFFER *wb);
@@ -35,7 +50,9 @@ const char *functions_content_type_to_format(HTTP_CONTENT_TYPE content_type);
int rrd_call_function_error(BUFFER *wb, const char *msg, int code);
int rrdhost_function_streaming(BUFFER *wb, int timeout, const char *function, void *collector_data,
- function_data_ready_callback callback, void *callback_data);
+ rrd_function_result_callback_t result_cb, void *result_cb_data,
+ rrd_function_is_cancelled_cb_t is_cancelled_cb, void *is_cancelled_cb_data,
+ rrd_function_register_canceller_cb_t register_canceller_cb, void *register_canceller_cb_data);
#define RRDFUNCTIONS_STREAMING_HELP "Streaming status for parents and children."