Commit Graph

38 Commits

Author SHA1 Message Date
Zaiming (Stone) Shi ac41f497b4 feat: add bytesize rule sql function 2023-09-15 16:04:21 +02:00
firest 9f38f5f26a fix(calendar): make date parse error reason more sense 2023-08-08 14:28:38 +08:00
Andrew Mayorov a51baaa206
refactor(pluglib): move conversion utils to `emqx_utils_conv` 2023-06-09 14:44:37 +03:00
Kjell Winblad 354603da01 test: helper function was interpreted as a test function 2023-05-29 17:20:37 +02:00
Kjell Winblad 995025b572 feat: add timezone_to_second/1 function to rule engine
This commit adds the functions timezone_to_offset_seconds and its alias
timezone_to_second to the rule engine. As the names suggests, these
functions convert a timzone offset string such as "+02:00", "Z", "local"
to an integer representing how many seconds that the given timezone
differs from UTC. timezone_to_offset_seconds is the one of the two
functions that should be advertised while timezone_to_second in kept for
backwards compatibility with 4.X.

Fixes:
https://emqx.atlassian.net/browse/EMQX-10058
2023-05-29 14:30:43 +02:00
firest 56a6b699ac fix: port the `emqx_calendar` from v4.4 2023-05-22 09:55:31 +08:00
Kjell Winblad 0c727fc9b2
Merge pull request #10392 from kjellwinblad/kjell/rule_engine/add_missing_datetime_function/EMQX-9245
freat: add date_to_unix_ts/3 function to the rule engine
2023-04-17 18:09:44 +02:00
Zaiming (Stone) Shi 18974a8e11 refactor: make schema dump and swagger spec work with split desc files 2023-04-17 13:58:11 +02:00
Kjell Winblad 37f42a486c test: improve proper test so it generates more cases 2023-04-17 12:03:13 +02:00
Zhongwen Deng 8facd130f6 chore: update cluster_hocon_file/0 function 2023-04-14 23:19:38 +08:00
Kjell Winblad d3ccd8a65d feat: add date_to_unix_ts/3 function to the rule engine
Fixes:
https://emqx.atlassian.net/browse/EMQX-9245
2023-04-13 16:14:03 +02:00
Thales Macedo Garitezi f3ffc02bff feat(bridges): enable async query mode for all bridges with buffer workers
Fixes https://emqx.atlassian.net/browse/EMQX-9130

Since buffer workers always support async calls ("outer calls"), we
should decouple those two call modes (inner and outer), and avoid
exposing the inner call configuration to user to avoid complexity.

For bridges that currently only allow sync query modes, we should
allow them to be configured with async.  That means basically all
bridge types except Kafka Producer.
2023-04-03 14:49:51 -03:00
Zaiming (Stone) Shi f5e9d3eab2 test: use valid config for jq function timeout 2023-03-28 14:29:24 +02:00
Zaiming (Stone) Shi dbc10c2eed chore: update copyright year 2023 2023-01-02 09:22:27 +01:00
JimMoen 4906da9796
test(rule-funcs): test compression funcs 2022-12-19 15:43:50 +08:00
Shawn 6685a3c5a8 fix: remove the 'headers' field from the rule events 2022-06-17 15:57:10 +08:00
Xinyu Liu 866810cea6
Merge pull request #8006 from emqx/copy-of-kjell/jq/timeout
feat(rule_engine): default timeout for jq/2 and jq/3 with timeout
2022-05-23 11:58:40 +08:00
EMQ-YangM 005fce63d1 feat: add rule engine function float2str/2 2022-05-19 16:16:05 +08:00
EMQ-YangM 66c62f432b fix: zero padding should be to the MSB side 2022-05-18 15:28:01 +08:00
Kjell Winblad 05032467bd feat(rule_engine): default timeout for jq/2 and jq/3 with timeout
This commit adds a default timeout of 10 seconds to the rule engine's
`jq/2` function, and adds a new function `jq/3` (where the last parameter is
a timeout value). The default timeout can be configured with the setting
"rule_engine.jq_function_default_timeout".

Having a timeout when executing jq code in the rule engine is important
as jq code can potentially run forever. Also, the Erlang jq library
limits the number of jq programs that can execute concurrently so a jq
program that loops forever could potentially also prevent a "non-buggy"
jq program from ever starting.
2022-05-17 19:36:32 +02:00
EMQ-YangM d8da8f1686 fix: hexstr_to_bin support half byte 2022-05-17 16:47:59 +08:00
Kjell Winblad 74c33cd4e5 feat(rule_engine): add jq function to the rule engine
This commit adds a function to the rule engine that alows users
to transform text or JSON objects using [jq filter programs][1].

[jq][1] is a command line tool that can be used to transform
and filter JSON text using jq's built-in language. The rule engine
function that is added with this commit uses the
[Erlang jq NIF library][2] that wraps the jq C library in an
Erlang NIF function.

[1]: https://stedolan.github.io/jq/
[2]: https://github.com/emqx/jq
2022-05-04 17:09:16 +02:00
Zaiming (Stone) Shi 02c3f87b31 style: reformat all remaining apps 2022-04-27 15:51:18 +02:00
EMQ-YangM e4b62f3a5f feat: add rule-engine functions 2022-04-15 18:02:24 +08:00
Kian-Meng Ang fc92e4c8bf docs: fix typos 2022-01-27 12:29:38 +01:00
Zaiming (Stone) Shi 63167cea70 chore: update copyright 2022-01-05 20:55:00 +01:00
lafirest 3524942766 fix: change all ~s in io format to ~ts
we should use unicode to replace latin1
2021-10-12 15:09:24 +08:00
Zaiming Shi 6354e75626 chore: update copyrights 2021-04-23 20:43:00 +02:00
Shawn 19a9bab3a4 feat(rule_engine): add rule sql functions for datetime rfc3339 2021-04-22 10:32:44 +08:00
Shawn 196fef0255 chore(rule): migrate rule-engine from enterprise version 2021-02-22 13:53:51 +08:00
Shawn c2e1bc039b
feat(rule): add more sql functions #4143 (#4144) 2021-02-20 17:10:10 +08:00
Zaiming Shi 4a877a3a69 chore(apps): relocate some apps
emqx_telemetry is for opensource onlyh
emqx_rule_engiune is common
2021-02-19 11:24:41 +01:00
Zaiming Shi 8f477e8411 refactor(proj): Move opensource apps to lib-opensource
One step closer for better code abstraction for opensorce vs enterprise
So far this relocation is to make opensource to enterprise merges
conflict free.
2021-02-11 16:45:05 +01:00
Shawn c3159420bb feat(funcs): add bitsize/1 and subbits/2,3,6 functions 2020-12-22 11:18:16 +08:00
Zaiming Shi 3a91ff8a7b chore(proj): resync apps 2020-12-11 08:19:26 +01:00
Shawn 15d048d8ec feat(funcs): add bitsize/1 and subbits/2,3,6 functions
Given following Rule SQL:

```
select
  subbits(payload, 1, 8) as firstByte,
  case
    when firstByte = 123 then 't/{'
    when firstByte = 125 then 't/}'
    else 't/' + str(firstByte)
  end as tp
from "t/#"
```

Input Payload: `{x}`
Output: `{"tp": "t/{", "firstByte": 123}`

Input Payload: `}x`
Output: `{"tp": "t/}", "firstByte": 125}`

Input Payload: `a`
Output: `{"tp": "t/97", "firstByte": 97}`
2020-12-10 11:26:07 +08:00
Zaiming Shi 2fda0a1565 chore(apps): Sync again all apps 2020-12-07 21:30:21 +01:00
Zaiming Shi 686c006d6e refactor(proj): Add apps 2020-12-04 22:11:53 +01:00