Merge pull request #7603 from EMQ-YangM/fix_zip_compress

fix: add zip_compress functions
This commit is contained in:
Xinyu Liu 2022-04-13 15:37:02 +08:00 committed by GitHub
commit 4e515a3f83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -31,6 +31,7 @@ File format:
node. It will improves the efficiency of shared messages dispatching in certain
scenarios, especially when the emqx-bridge-mqtt plugin is configured as shared
subscription. [#7462]
* Add some compression functions to rule-engine: gzip, gunzip, zip, unzip, zip_compress, zip_uncompress
### Bug fixes

View File

@ -179,6 +179,11 @@
, unzip/1
]).
%% compressed Funcs
-export([ zip_compress/1
, zip_uncompress/1
]).
%% Data encode and decode
-export([ base64_encode/1
, base64_decode/1
@ -817,6 +822,16 @@ zip(S) when is_binary(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

@ -632,6 +632,17 @@ prop_zip_fun() ->
?FORALL(S, binary(),
S == apply_func(unzip, [apply_func(zip, [S])])).
%%------------------------------------------------------------------------------
%% Test cases for zip funcs
%%------------------------------------------------------------------------------
t_zip_compress_funcs(_) ->
?PROPTEST(prop_zip_compress_fun).
prop_zip_compress_fun() ->
?FORALL(S, binary(),
S == apply_func(zip_uncompress, [apply_func(zip_compress, [S])])).
%%------------------------------------------------------------------------------
%% Test cases for base64
%%------------------------------------------------------------------------------