Skip to content

Commit

Permalink
Merge pull request #26 from emqx/fix-introduced-guard-bug
Browse files Browse the repository at this point in the history
fix: fix recently introduced guard bug
  • Loading branch information
mononym authored Mar 21, 2022
2 parents 25da12e + 4124b26 commit 3a388dd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mongoc/mc_topology_logics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
-include("mongoc.hrl").

-define(NON_SHARDED(ST),
ST =:= standalone; ST =:= rsPrimary; ST =:= rsSecondary; ST =:= rsArbiter; ST =:= rsOther; ST =:= rsGhost).
-define(SEC_ARB_OTH(ST), ST =:= rsSecondary; ST =:= rsArbiter; ST =:= rsOther).
-define(STAL_MONGS(ST), ST =:= standalone; ST =:= mongos).
-define(UNKN_GHST(ST), ST =:= unknown; ST =:= rsGhost).
-define(NOT_MAX(E, M), E =/= undefined, M =/= undefined, E < M).
(ST =:= standalone orelse ST =:= rsPrimary orelse ST =:= rsSecondary orelse ST =:= rsArbiter orelse ST =:= rsOther orelse ST =:= rsGhost)).
-define(SEC_ARB_OTH(ST), (ST =:= rsSecondary orelse ST =:= rsArbiter orelse ST =:= rsOther)).
-define(STAL_MONGS(ST), (ST =:= standalone orelse ST =:= mongos)).
-define(UNKN_GHST(ST), (ST =:= unknown orelse ST =:= rsGhost)).
-define(NOT_MAX(E, M), (E =/= undefined andalso M =/= undefined andalso E < M)).

-define(LOG_TOPOLOGY_ERROR(Configured, Actual),
logger:error("Configured mongo client topology does not match actual mongo install topology. Configured: ~p; Actual: ~p", [Configured, Actual])).
Expand Down Expand Up @@ -153,19 +153,19 @@ validate_server_and_config(ConnectArgs, TopologyType, TopologySetName) ->
?LOG_TOPOLOGY_ERROR(replicaSetNoPrimary, ServerType),
{configured_mongo_type_mismatch, TopologyType, ServerType};

replicaSetNoPrimary when ?SEC_ARB_OTH(ServerType), ServerSetName /= TopologySetName, TopologySetName /= undefined ->
replicaSetNoPrimary when ?SEC_ARB_OTH(ServerType) andalso ServerSetName /= TopologySetName andalso TopologySetName /= undefined ->
?LOG_SET_NAME_ERROR(TopologySetName, ServerSetName),
{configured_mongo_set_name_mismatch, TopologySetName, ServerSetName};

replicaSetWithPrimary when ?STAL_MONGS(ServerType) ->
?LOG_TOPOLOGY_ERROR(replicaSetWithPrimary, ServerType),
{configured_mongo_type_mismatch, TopologyType, ServerType};

replicaSetWithPrimary when ?SEC_ARB_OTH(ServerType), ServerSetName /= TopologySetName ->
replicaSetWithPrimary when ?SEC_ARB_OTH(ServerType) andalso ServerSetName /= TopologySetName ->
?LOG_SET_NAME_ERROR(TopologySetName, ServerSetName),
{configured_mongo_set_name_mismatch, TopologySetName, ServerSetName};

_ when ServerType == rsPrimary, ServerSetName /= TopologySetName ->
_ when ServerType == rsPrimary andalso ServerSetName /= TopologySetName ->
?LOG_SET_NAME_ERROR(TopologySetName, ServerSetName),
{configured_mongo_set_name_mismatch, TopologySetName, ServerSetName};

Expand Down

0 comments on commit 3a388dd

Please sign in to comment.