fix(connector): fix schema error for mongo

This commit is contained in:
zhanghongtong 2021-08-12 15:37:13 +08:00 committed by Rory Z
parent 8597591e80
commit 618125b1da
1 changed files with 6 additions and 2 deletions

View File

@ -62,7 +62,8 @@ fields(sharded) ->
, {servers, fun servers/1} , {servers, fun servers/1}
] ++ mongo_fields(); ] ++ mongo_fields();
fields(topology) -> fields(topology) ->
[ {max_overflow, fun emqx_connector_schema_lib:pool_size/1} [ {pool_size, fun emqx_connector_schema_lib:pool_size/1}
, {max_overflow, fun emqx_connector_schema_lib:pool_size/1}
, {overflow_ttl, fun duration/1} , {overflow_ttl, fun duration/1}
, {overflow_check_period, fun duration/1} , {overflow_check_period, fun duration/1}
, {local_threshold_ms, fun duration/1} , {local_threshold_ms, fun duration/1}
@ -81,6 +82,8 @@ mongo_fields() ->
, {auth_source, #{type => binary(), , {auth_source, #{type => binary(),
nullable => true}} nullable => true}}
, {database, fun emqx_connector_schema_lib:database/1} , {database, fun emqx_connector_schema_lib:database/1}
, {topology, #{type => hoconsc:ref(?MODULE, topology),
nullable => true}}
] ++ ] ++
emqx_connector_schema_lib:ssl_fields(). emqx_connector_schema_lib:ssl_fields().
@ -170,9 +173,10 @@ do_start(InstId, Opts0, Config = #{mongo_type := Type,
]; ];
false -> [{ssl, false}] false -> [{ssl, false}]
end, end,
Topology= maps:get(topology, Config, #{}),
Opts = Opts0 ++ Opts = Opts0 ++
[{pool_size, PoolSize}, [{pool_size, PoolSize},
{options, init_topology_options(maps:to_list(Config), [])}, {options, init_topology_options(maps:to_list(Topology), [])},
{worker_options, init_worker_options(maps:to_list(Config), SslOpts)}], {worker_options, init_worker_options(maps:to_list(Config), SslOpts)}],
%% test the connection %% test the connection
TestOpts = case maps:is_key(server, Config) of TestOpts = case maps:is_key(server, Config) of