Merge pull request #7603 from EMQ-YangM/fix_zip_compress
fix: add zip_compress functions
This commit is contained in:
commit
4e515a3f83
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
%%------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
%%------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue