fix: topic rewrite action type add all

This commit is contained in:
DDDHuang 2021-09-15 15:27:25 +08:00 committed by DDDHuang
parent 6c2c64118e
commit 60e815fb9a
4 changed files with 17 additions and 3 deletions

View File

@ -33,6 +33,18 @@ rewrite: [
# source_topic = "x/#"
# re = "^x/y/(.+)$"
# dest_topic = "z/y/$1"
# },
# {
# action = subscribe
# source_topic = "x1/#"
# re = "^x1/y/(.+)$"
# dest_topic = "z1/y/$1"
# },
# {
# action = all
# source_topic = "x2/#"
# re = "^x2/y/(.+)$"
# dest_topic = "z2/y/$1"
# }
]

View File

@ -45,7 +45,7 @@ fields("delayed") ->
];
fields("rewrite") ->
[ {action, hoconsc:enum([publish, subscribe])}
[ {action, hoconsc:enum([publish, subscribe, all])}
, {source_topic, sc(binary(), #{})}
, {re, sc(binary(), #{})}
, {dest_topic, sc(binary(), #{})}

View File

@ -95,7 +95,9 @@ compile(Rules) ->
publish ->
{[{Topic, MP, Dest} | Acc1], Acc2};
subscribe ->
{Acc1, [{Topic, MP, Dest} | Acc2]}
{Acc1, [{Topic, MP, Dest} | Acc2]};
all ->
{[{Topic, MP, Dest} | Acc1], [{Topic, MP, Dest} | Acc2]}
end
end, {[], []}, Rules).

View File

@ -35,7 +35,7 @@ api_spec() ->
{[rewrite_api()], []}.
properties() ->
properties([{action, string, <<"Node">>, [subscribe, publish]},
properties([{action, string, <<"Action">>, [subscribe, publish, all]},
{source_topic, string, <<"Topic">>},
{re, string, <<"Regular expressions">>},
{dest_topic, string, <<"Destination topic">>}]).