CONSTRUCTOR: <mdb-connection> mdb-connection ( instance -- mdb-connection ) ;
: check-ok ( result -- errmsg ? )
- [ [ "errmsg" ] dip at ]
- [ [ "ok" ] dip at ] bi ; inline
+ [ [ "errmsg" ] dip at ]
+ [ [ "ok" ] dip at ] bi ; inline
: <mdb-db> ( name nodes -- mdb-db )
mdb-db new swap >>nodes swap >>name H{ } clone >>collections ;
: with-connection ( connection quot -- * )
[ mdb-connection ] dip with-variable ; inline
-
+
: mdb-instance ( -- mdb )
mdb-connection get instance>> ; inline
[ "nonce" of ] [ f ] if* ;
: auth? ( mdb -- ? )
- [ username>> ] [ pwd-digest>> ] bi and ;
+ [ username>> ] [ pwd-digest>> ] bi and ;
: calculate-key-digest ( nonce -- digest )
mdb-instance
mdb-instance username>> "user" set-cmd-opt
get-nonce [ "nonce" set-cmd-opt ] [ ] bi
calculate-key-digest "key" set-cmd-opt ; inline
-
+
: perform-authentication ( -- )
authenticate-cmd make-cmd
build-auth-cmd send-cmd
[ >>handle ] dip >>local 4096 <byte-vector> >>buffer ;
: get-ismaster ( -- result )
- "admin.$cmd" H{ { "ismaster" 1 } } send-query-1result ;
+ "admin.$cmd" H{ { "ismaster" 1 } } send-query-1result ;
: split-host-str ( hoststr -- host port )
":" split [ first ] [ second string>number ] bi ; inline
[ drop f ] if* :> node2
node1 [ acc push ] when*
node2 [ acc push ] when*
- mdb acc nodelist>table >>nodes drop
+ mdb acc nodelist>table >>nodes drop
] with-destructors ;
ERROR: mongod-connection-error address message ;
-
+
: mdb-open ( mdb -- mdb-connection )
clone [ verify-nodes ] [ <mdb-connection> ] [ ] tri
master-node [