Closed terry-xiaoyu closed 1 year ago
@terry-xiaoyu can you explain what the purpose of the ping command is. Could the user not get the same functionality from calling the command
functions?
@terry-xiaoyu can you explain what the purpose of the ping command is. Could the user not get the same functionality from calling the
command
functions?
Will be called by emqx_backend_mongo_actions:on_get_resource_status
, I added some descriptions to this PR just now.
According to the existing design, the user can only call the APIs exported by mongo_api
, so to follow its style, I added a new API ping
to mongo_api
, and also a ping_query
function to pack the ping record.
I think it is better to add a command/2
function to the mongo_api
module that is similar to the command/2
function in the mc_worker_api
module. Then we will have a much more general function that can be used to execute many Mongo DB commands and not only ping.
@terry-xiaoyu what do you think?
I think it is better to add a
command/2
function to themongo_api
module that is similar to thecommand/2
function in themc_worker_api
module. Then we will have a much more general function that can be used to execute many Mongo DB commands and not only ping.@terry-xiaoyu what do you think?
OK, I will add a command API too.
Updated:
Added the mongo_api:command/3
, and removed the ping API.
Add
mongo_api:ping/2
for health check purposes. It will be called by theemqx_backend_mongo_actions:on_get_resource_status
to test if the connection between emqx and mongodb works well.Before this change, we have to use
mongo_api:find_one(Conn, <<"foo">>, {}, #{}, 0, infinity)
to test the connectivity, where <<"foo">> is a dummy collection may or may not be present in the mongodb.