Преглед изворни кода

fix(emqx_authn): add default wait_connected

EMQ-YangM пре 3 година
родитељ
комит
d99db4ebfa

+ 2 - 1
apps/emqx_authn/src/simple_authn/emqx_authn_http.erl

@@ -133,7 +133,8 @@ create(#{method := Method,
                                     ?RESOURCE_GROUP,
                                     ?RESOURCE_GROUP,
                                     emqx_connector_http,
                                     emqx_connector_http,
                                     Config#{base_url => maps:remove(query, URIMap),
                                     Config#{base_url => maps:remove(query, URIMap),
-                                            pool_type => random}) of
+                                            pool_type => random},
+                                            #{wait_connected => 1000}) of
         {ok, already_created} ->
         {ok, already_created} ->
             {ok, State};
             {ok, State};
         {ok, _} ->
         {ok, _} ->

+ 1 - 1
apps/emqx_authn/src/simple_authn/emqx_authn_mongodb.erl

@@ -112,7 +112,7 @@ create(#{selector := Selector} = Config) ->
     NState = State#{
     NState = State#{
                selector_template => SelectorTemplate,
                selector_template => SelectorTemplate,
                resource_id => ResourceId},
                resource_id => ResourceId},
-    case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP, emqx_connector_mongo, Config) of
+    case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP, emqx_connector_mongo, Config,  #{wait_connected => 1000}) of
         {ok, already_created} ->
         {ok, already_created} ->
             {ok, NState};
             {ok, NState};
         {ok, _} ->
         {ok, _} ->

+ 1 - 1
apps/emqx_authn/src/simple_authn/emqx_authn_mysql.erl

@@ -81,7 +81,7 @@ create(#{password_hash_algorithm := Algorithm,
               placeholders => PlaceHolders,
               placeholders => PlaceHolders,
               query_timeout => QueryTimeout,
               query_timeout => QueryTimeout,
               resource_id => ResourceId},
               resource_id => ResourceId},
-    case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP, emqx_connector_mysql, Config) of
+    case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP, emqx_connector_mysql, Config, #{wait_connected => 1000}) of
         {ok, already_created} ->
         {ok, already_created} ->
             {ok, State};
             {ok, State};
         {ok, _} ->
         {ok, _} ->

+ 3 - 1
apps/emqx_authn/src/simple_authn/emqx_authn_pgsql.erl

@@ -79,7 +79,9 @@ create(#{query := Query0,
     State = #{placeholders => PlaceHolders,
     State = #{placeholders => PlaceHolders,
               password_hash_algorithm => Algorithm,
               password_hash_algorithm => Algorithm,
               resource_id => ResourceId},
               resource_id => ResourceId},
-    case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP, emqx_connector_pgsql, Config#{named_queries => #{ResourceId => Query}}) of
+    case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP, emqx_connector_pgsql,
+                                    Config#{named_queries => #{ResourceId => Query}},
+                                    #{wait_connected => 1000}) of
         {ok, already_created} ->
         {ok, already_created} ->
             {ok, State};
             {ok, State};
         {ok, _} ->
         {ok, _} ->

+ 3 - 1
apps/emqx_authn/src/simple_authn/emqx_authn_redis.erl

@@ -91,7 +91,9 @@ create(#{cmd := Cmd,
         NState = State#{
         NState = State#{
                    cmd => NCmd,
                    cmd => NCmd,
                    resource_id => ResourceId},
                    resource_id => ResourceId},
-        case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP, emqx_connector_redis, Config) of
+        case emqx_resource:create_local(ResourceId, ?RESOURCE_GROUP,
+                                        emqx_connector_redis, Config,
+                                        #{wait_connected => 1000}) of
             {ok, already_created} ->
             {ok, already_created} ->
                 {ok, NState};
                 {ok, NState};
             {ok, _} ->
             {ok, _} ->