소스 검색

Merge pull request #10506 from lafirest/fix/dynamo_default_port

fix(dynamo): use correct default port for different schemas
lafirest 2 년 전
부모
커밋
dc452deaf0
1개의 변경된 파일8개의 추가작업 그리고 12개의 파일을 삭제
  1. 8 12
      lib-ee/emqx_ee_connector/src/emqx_ee_connector_dynamo.erl

+ 8 - 12
lib-ee/emqx_ee_connector/src/emqx_ee_connector_dynamo.erl

@@ -33,10 +33,6 @@
 
 -import(hoconsc, [mk/2, enum/1, ref/2]).
 
--define(DYNAMO_HOST_OPTIONS, #{
-    default_port => 80
-}).
-
 %%=====================================================================
 %% Hocon schema
 roots() ->
@@ -84,8 +80,8 @@ on_start(
         config => redact(Config)
     }),
 
-    {Schema, Server} = get_host_schema(to_str(Url)),
-    {Host, Port} = emqx_schema:parse_server(Server, ?DYNAMO_HOST_OPTIONS),
+    {Schema, Server, DefaultPort} = get_host_info(to_str(Url)),
+    {Host, Port} = emqx_schema:parse_server(Server, #{default_port => DefaultPort}),
 
     Options = [
         {config, #{
@@ -226,12 +222,12 @@ to_str(List) when is_list(List) ->
 to_str(Bin) when is_binary(Bin) ->
     erlang:binary_to_list(Bin).
 
-get_host_schema("http://" ++ Server) ->
-    {"http://", Server};
-get_host_schema("https://" ++ Server) ->
-    {"https://", Server};
-get_host_schema(Server) ->
-    {"http://", Server}.
+get_host_info("http://" ++ Server) ->
+    {"http://", Server, 80};
+get_host_info("https://" ++ Server) ->
+    {"https://", Server, 443};
+get_host_info(Server) ->
+    {"http://", Server, 80}.
 
 redact(Data) ->
     emqx_utils:redact(Data, fun(Any) -> Any =:= aws_secret_access_key end).