fix(bridge): update emqx_bridge.conf
This commit is contained in:
parent
a9c9d9d805
commit
05e24b457a
|
@ -9,10 +9,10 @@
|
||||||
# direction = ingress
|
# direction = ingress
|
||||||
# ## topic mappings for this bridge
|
# ## topic mappings for this bridge
|
||||||
# remote_topic = "aws/#"
|
# remote_topic = "aws/#"
|
||||||
# subscribe_qos = 1
|
# remote_qos = 1
|
||||||
# local_topic = "from_aws/${topic}"
|
# local_topic = "from_aws/${topic}"
|
||||||
|
# local_qos = "${qos}"
|
||||||
# payload = "${payload}"
|
# payload = "${payload}"
|
||||||
# qos = "${qos}"
|
|
||||||
# retain = "${retain}"
|
# retain = "${retain}"
|
||||||
#}
|
#}
|
||||||
#
|
#
|
||||||
|
@ -23,14 +23,15 @@
|
||||||
# ## topic mappings for this bridge
|
# ## topic mappings for this bridge
|
||||||
# local_topic = "emqx/#"
|
# local_topic = "emqx/#"
|
||||||
# remote_topic = "from_emqx/${topic}"
|
# remote_topic = "from_emqx/${topic}"
|
||||||
|
# remote_qos = "${qos}"
|
||||||
# payload = "${payload}"
|
# payload = "${payload}"
|
||||||
# qos = 1
|
|
||||||
# retain = false
|
# retain = false
|
||||||
#}
|
#}
|
||||||
#
|
#
|
||||||
## HTTP bridges to an HTTP server
|
## HTTP bridges to an HTTP server
|
||||||
#bridges.http.my_http_bridge {
|
#bridges.http.my_http_bridge {
|
||||||
# enable = true
|
# enable = true
|
||||||
|
# direction = egress
|
||||||
# ## NOTE: we cannot use placehodler variables in the `scheme://host:port` part of the url
|
# ## NOTE: we cannot use placehodler variables in the `scheme://host:port` part of the url
|
||||||
# url = "http://localhost:9901/messages/${topic}"
|
# url = "http://localhost:9901/messages/${topic}"
|
||||||
# request_timeout = "30s"
|
# request_timeout = "30s"
|
||||||
|
@ -47,7 +48,7 @@
|
||||||
# cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem"
|
# cacertfile = "{{ platform_etc_dir }}/certs/cacert.pem"
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# from_local_topic = "emqx_http/#"
|
# local_topic = "emqx_http/#"
|
||||||
# ## the following config entries can use placehodler variables:
|
# ## the following config entries can use placehodler variables:
|
||||||
# ## url, method, body, headers
|
# ## url, method, body, headers
|
||||||
# method = post
|
# method = post
|
||||||
|
|
|
@ -68,14 +68,9 @@ load_hook(Bridges) ->
|
||||||
end, maps:to_list(Bridges)).
|
end, maps:to_list(Bridges)).
|
||||||
|
|
||||||
do_load_hook(#{local_topic := _} = Conf) ->
|
do_load_hook(#{local_topic := _} = Conf) ->
|
||||||
case maps:find(direction, Conf) of
|
case maps:get(direction, Conf, egress) of
|
||||||
error ->
|
egress -> emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []});
|
||||||
%% this bridge has no direction field, it means that it has only egress bridges
|
ingress -> ok
|
||||||
emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []});
|
|
||||||
{ok, egress} ->
|
|
||||||
emqx_hooks:put('message.publish', {?MODULE, on_message_publish, []});
|
|
||||||
{ok, ingress} ->
|
|
||||||
ok
|
|
||||||
end;
|
end;
|
||||||
do_load_hook(_Conf) -> ok.
|
do_load_hook(_Conf) -> ok.
|
||||||
|
|
||||||
|
@ -276,10 +271,8 @@ get_matched_bridges(Topic) ->
|
||||||
(_BName, #{direction := ingress}, Acc1) ->
|
(_BName, #{direction := ingress}, Acc1) ->
|
||||||
Acc1;
|
Acc1;
|
||||||
(BName, #{direction := egress} = Egress, Acc1) ->
|
(BName, #{direction := egress} = Egress, Acc1) ->
|
||||||
get_matched_bridge_id(Egress, Topic, BType, BName, Acc1);
|
|
||||||
%% HTTP, MySQL bridges only have egress direction
|
%% HTTP, MySQL bridges only have egress direction
|
||||||
(BName, BridgeConf, Acc1) ->
|
get_matched_bridge_id(Egress, Topic, BType, BName, Acc1)
|
||||||
get_matched_bridge_id(BridgeConf, Topic, BType, BName, Acc1)
|
|
||||||
end, Acc0, Conf)
|
end, Acc0, Conf)
|
||||||
end, [], Bridges).
|
end, [], Bridges).
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,10 @@ basic_config() ->
|
||||||
#{ desc => "Enable or disable this bridge"
|
#{ desc => "Enable or disable this bridge"
|
||||||
, default => true
|
, default => true
|
||||||
})}
|
})}
|
||||||
|
, {direction,
|
||||||
|
mk(egress,
|
||||||
|
#{ desc => "The direction of this bridge, MUST be egress"
|
||||||
|
})}
|
||||||
]
|
]
|
||||||
++ proplists:delete(base_url, emqx_connector_http:fields(config)).
|
++ proplists:delete(base_url, emqx_connector_http:fields(config)).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue