feat(rule-engine): `zip`, `gzip`, `zip_compress` funcs in rule-sql

This commit is contained in:
JimMoen 2022-12-19 15:34:57 +08:00
parent d245a9909d
commit 5151242583
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
4 changed files with 53 additions and 1 deletions

View File

@ -2,7 +2,7 @@
{application, emqx_rule_engine, [
{description, "EMQX Rule Engine"},
% strict semver, bump manually!
{vsn, "5.0.5"},
{vsn, "5.0.6"},
{modules, []},
{registered, [emqx_rule_engine_sup, emqx_rule_engine]},
{applications, [kernel, stdlib, rulesql, getopt]},

View File

@ -187,6 +187,24 @@
sha256/1
]).
%% zip Funcs
-export([
zip/1,
unzip/1
]).
%% gzip Funcs
-export([
gzip/1,
gunzip/1
]).
%% compressed Funcs
-export([
zip_compress/1,
zip_uncompress/1
]).
%% Data encode and decode
-export([
base64_encode/1,
@ -928,6 +946,36 @@ sha256(S) when is_binary(S) ->
hash(Type, Data) ->
emqx_misc:bin_to_hexstr(crypto:hash(Type, Data), lower).
%%------------------------------------------------------------------------------
%% gzip Funcs
%%------------------------------------------------------------------------------
gzip(S) when is_binary(S) ->
zlib:gzip(S).
gunzip(S) when is_binary(S) ->
zlib:gunzip(S).
%%------------------------------------------------------------------------------
%% zip Funcs
%%------------------------------------------------------------------------------
zip(S) when is_binary(S) ->
zlib:zip(S).
unzip(S) when is_binary(S) ->
zlib:unzip(S).
%%------------------------------------------------------------------------------
%% zip_compress Funcs
%%------------------------------------------------------------------------------
zip_compress(S) when is_binary(S) ->
zlib:compress(S).
zip_uncompress(S) when is_binary(S) ->
zlib:uncompress(S).
%%------------------------------------------------------------------------------
%% Data encode and decode Funcs
%%------------------------------------------------------------------------------

View File

@ -10,6 +10,8 @@
- Refactor: use `POST` not `PUT` for `/users/{name}/change_pwd` [#9533](https://github.com/emqx/emqx/pull/9533).
- Add compression functions `zip`, `gzip`, `zip_compress` in Rule-Engine and corresponding decompression functions [#9573](https://github.com/emqx/emqx/pull/9573).
## Bug fixes
- Trigger `message.dropped` hook when QoS2 message is resend by client with a same packet id, or 'awaiting_rel' queue is full [#9487](https://github.com/emqx/emqx/pull/9487).

View File

@ -10,6 +10,8 @@
- 重构: `/users/{name}/change_pwd` 的请求方式从 `PUT` 改为了 `POST` [#9533](https://github.com/emqx/emqx/pull/9533)。
- 规则引擎支持压缩函数 `zip`, `gzip`, `zip_compress` 及对应的解压缩函数 [#9573](https://github.com/emqx/emqx/pull/9573)。
## 修复
- 当 QoS2 消息被重发(使用相同 Packet ID),或当 'awaiting_rel' 队列已满时,触发消息丢弃钩子(`message.dropped`)及计数器 [#9487](https://github.com/emqx/emqx/pull/9487)。