perform the heavy job in a dedicated task and allow remaining events to be
processed more quickly.
+.. js:function:: core.disable_legacy_mailers()
+
+ **LEGACY**
+
+ **context**: body, init
+
+ Disable the sending of email alerts through the legacy email sending
+ function when mailers are used in the configuration.
+
+ Use this when sending email alerts directly from lua.
+
.. _proxy_class:
Proxy class
#include <haproxy/server-t.h>
extern struct mailers *mailers;
+extern int send_email_disabled;
int init_email_alert(struct mailers *mailers, struct proxy *p, char **err);
void send_email_alert(struct server *s, int priority, const char *format, ...)
#include <haproxy/xref.h>
#include <haproxy/event_hdl.h>
#include <haproxy/check.h>
+#include <haproxy/mailers.h>
/* Lua uses longjmp to perform yield or throwing errors. This
* macro is used only for identifying the function that can
return 0;
}
+/* This function disables the sending of email through the
+ * legacy email sending function which is implemented using
+ * checks.
+ *
+ * It may not be used during runtime.
+ */
+__LJMP static int hlua_disable_legacy_mailers(lua_State *L)
+{
+ if (hlua_gethlua(L))
+ WILL_LJMP(luaL_error(L, "disable_legacy_mailers: "
+ "not available outside of init or body context"));
+ send_email_disabled = 1;
+ return 0;
+}
+
/* A class is a lot of memory that contain data. This data can be a table,
* an integer or user data. This data is associated with a metatable. This
* metatable have an original version registered in the global context with
hlua_class_function(L, "Warning", hlua_log_warning);
hlua_class_function(L, "Alert", hlua_log_alert);
hlua_class_function(L, "done", hlua_done);
+ hlua_class_function(L, "disable_legacy_mailers", hlua_disable_legacy_mailers);
hlua_fcn_reg_core_fcn(L);
lua_setglobal(L, "core");
struct mailers *mailers = NULL;
+/* Set to 1 to disable email sending through checks even if the
+ * mailers are configured to do so. (e.g.: disable from lua)
+ */
+int send_email_disabled = 0;
+
DECLARE_STATIC_POOL(pool_head_email_alert, "email_alert", sizeof(struct email_alert));
/****************************** Email alerts ******************************/
int len;
struct proxy *p = s->proxy;
+ if (send_email_disabled)
+ return;
+
if (!p->email_alert.mailers.m || level > p->email_alert.level || format == NULL)
return;