Skip to content

Commit

Permalink
Add is_master method to mongo object.
Browse files Browse the repository at this point in the history
  • Loading branch information
lehenbauer committed Feb 12, 2014
1 parent 3839a67 commit 6561bed
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions generic/mongotcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
"reconnect",
"disconnect",
"check_connection",
"is_master",
"write_concern",
"run_command",
"replica_set_init",
Expand Down Expand Up @@ -614,6 +615,7 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
OPT_RECONNECT,
OPT_DISCONNECT,
OPT_CHECK_CONNECTION,
OPT_IS_MASTER,
OPT_WRITE_CONCERN,
OPT_RUN_COMMAND,
OPT_REPLICA_SET_INIT,
Expand Down Expand Up @@ -1205,6 +1207,29 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
break;
}

case OPT_IS_MASTER: {
bson *bsonResult;

if (objc != 3) {
Tcl_WrongNumArgs (interp, 1, objv, "is_master bsonResult");
return TCL_ERROR;
}

if (mongotcl_cmdNameObjToBson (interp, objv[3], &bsonResult) == TCL_ERROR) {
Tcl_AddErrorInfo (interp, "while locating bson result object");
return TCL_ERROR;
}


if (mongo_cmd_ismaster (md->conn, bsonResult) == MONGO_OK) {
Tcl_SetObjResult (interp, Tcl_NewIntObj(1));
} else {
Tcl_SetObjResult (interp, Tcl_NewIntObj(0));
}

break;
}

case OPT_REPLICA_SET_INIT: {
if (objc != 3) {
Tcl_WrongNumArgs (interp, 2, objv, "setname");
Expand Down

0 comments on commit 6561bed

Please sign in to comment.