rspamd_expression
This module can be used to implement different logic expressions in lua using rspamd AST optimizer. There are some examples in individual methods definitions to help understanding of this module.
Functions:
Function | Description |
---|---|
rspamd_expression.create(line, {parse_func, [process_func]}, pool) |
Create expression from the line using atom parsing routines and the specified memory pool. |
Methods:
Method | Description |
---|---|
rspamd_expression:to_string() |
Converts rspamd expression to string. |
rspamd_expression:process([callback, ]input[, flags]) |
Executes the expression and pass input to process atom callbacks. |
rspamd_expression:process_traced([callback, ]input[, flags]) |
Executes the expression and pass input to process atom callbacks. |
rspamd_expression:atoms() |
Extract all atoms from the expression as table of strings. |
The module rspamd_expression
defines the following functions.
rspamd_expression.create(line, {parse_func, [process_func]}, pool)
Create expression from the line using atom parsing routines and the specified memory pool
Parameters:
line {string}
: expression lineatom_functions {table}
: parse_atom function and optional process_atom functionmemory {rspamd_mempool}
: pool to use for this functionReturns:
{expr, err}
: expression object and error message of expr
is nilBack to module description.
The module rspamd_expression
defines the following methods.
rspamd_expression:to_string()
Converts rspamd expression to string
Parameters:
No parameters
Returns:
{string}
: string representation of rspamd expressionBack to module description.
rspamd_expression:process([callback, ]input[, flags])
Executes the expression and pass input to process atom callbacks
Parameters:
callback {function}
: if not specified on process, then callback must be hereinput {any}
: input data for processing callbacksReturns:
{number}
: result of the expression evaluationBack to module description.
rspamd_expression:process_traced([callback, ]input[, flags])
Executes the expression and pass input to process atom callbacks. This function also saves the full trace
Parameters:
callback {function}
: if not specified on process, then callback must be hereinput {any}
: input data for processing callbacksReturns:
{number, table of matched atoms}
: result of the expression evaluationBack to module description.
rspamd_expression:atoms()
Extract all atoms from the expression as table of strings
Parameters:
No parameters
Returns:
{table/strings}
: list of all atoms in the expressionBack to module description.
Back to top.