fix(bridge): update emqx_bridge.conf

This commit is contained in:
Shawn 2021-12-18 20:53:14 +08:00
parent a9c9d9d805
commit 05e24b457a
3 changed files with 15 additions and 17 deletions

View File

@ -9,10 +9,10 @@
# direction = ingress
# ## topic mappings for this bridge
# remote_topic = "aws/#"
# subscribe_qos = 1
# remote_qos = 1
# local_topic = "from_aws/${topic}"
# local_qos = "${qos}"
# payload = "${payload}"
# qos = "${qos}"
# retain = "${retain}"
#}
#
@ -23,14 +23,15 @@
# ## topic mappings for this bridge
# local_topic = "emqx/#"
# remote_topic = "from_emqx/${topic}"
# remote_qos = "${qos}"
# payload = "${payload}"
# qos = 1
# retain = false
#}
#
## HTTP bridges to an HTTP server
#bridges.http.my_http_bridge {
# enable = true
# direction = egress
# ## NOTE: we cannot use placehodler variables in the `scheme://host:port` part of the url
# url = "http://localhost:9901/messages/${topic}"
# request_timeout = "30s"
@ -47,7 +48,7 @@
# cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem"
# }
#
# from_local_topic = "emqx_http/#"
# local_topic = "emqx_http/#"
# ## the following config entries can use placehodler variables:
# ## url, method, body, headers
# method = post

View File

@ -68,14 +68,9 @@ load_hook(Bridges) ->
end, maps:to_list(Bridges)).
do_load_hook(#{local_topic := _} = Conf) ->
case maps:find(direction, Conf) of
error ->
%% this bridge has no direction field, it means that it has only egress bridges
emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []});
{ok, egress} ->
emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []});
{ok, ingress} ->
ok
case maps:get(direction, Conf, egress) of
egress -> emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []});
ingress -> ok
end;
do_load_hook(_Conf) -> ok.
@ -276,10 +271,8 @@ get_matched_bridges(Topic) ->
(_BName, #{direction := ingress}, Acc1) ->
Acc1;
(BName, #{direction := egress} = Egress, Acc1) ->
get_matched_bridge_id(Egress, Topic, BType, BName, Acc1);
%% HTTP, MySQL bridges only have egress direction
(BName, BridgeConf, Acc1) ->
get_matched_bridge_id(BridgeConf, Topic, BType, BName, Acc1)
get_matched_bridge_id(Egress, Topic, BType, BName, Acc1)
end, Acc0, Conf)
end, [], Bridges).

View File

@ -84,6 +84,10 @@ basic_config() ->
#{ desc => "Enable or disable this bridge"
, default => true
})}
, {direction,
mk(egress,
#{ desc => "The direction of this bridge, MUST be egress"
})}
]
++ proplists:delete(base_url, emqx_connector_http:fields(config)).