diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-12-02 10:06:21 +0100 |
commit | fd841e416881cc0392e61ec312c1870f3a0004bd (patch) | |
tree | 8357ba56e79d614ba57f722e7878b853591dc339 /docs/tutorial/tut_mongo_sync_connect.h |
Initial import of libmongo-client version 0.1.8-2
Diffstat (limited to 'docs/tutorial/tut_mongo_sync_connect.h')
-rw-r--r-- | docs/tutorial/tut_mongo_sync_connect.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/docs/tutorial/tut_mongo_sync_connect.h b/docs/tutorial/tut_mongo_sync_connect.h new file mode 100644 index 0000000..1fb8b4a --- /dev/null +++ b/docs/tutorial/tut_mongo_sync_connect.h @@ -0,0 +1,49 @@ +/** @page tut_mongo_sync_connect Connecting to MongoDB + * + * The next step in our journey is to connect to MongoDB: to a single + * server and to a replicaset alike. + * + * Our first task is to connect to a MongoDB server, listening + * on localhost's 27017 port. And we don't care whether it is a master + * or a secondary, so we set the slave_ok argument to TRUE: + * + * @dontinclude tut_mongo_sync.c + * @skip void + * @until mongo_sync_disconnect + * @until } + * + * It's fairly straightforward: error handling is done using errno + * values, because that saves us from inventing our own statuses: + * POSIX provides us with plenty, and the C library uses errno + * extensively well. So does libmongo-client! + * + * Next up, is connecting to a replicaset: + * + * @until return; + * @until } + * + * Wait a minute! Does this look familiar? Isn't it @b exactly the + * same as in the former example (apart from the host name)? It sure + * is! There really is no difference between connecting to a single + * server and to a replica set when using the Sync API. It hides all + * the boring things from the user. + * + * However, if the server is a replicaset, we can add seeds: seeds are + * hosts that are not listed in the replicaset's public config + * (meaning they're hidden), but we still want to be able to use them, + * if so need be. + * + * It's not neccessary to add seeds, if the replica set itself + * advertises secondaries: the library will discover those, and + * reconnect to them, if automatic reconnection is turned on. Lets + * just do that! + * + * @until } + * + * Then we can add the seeds: + * @until } + * @until } + * + * And that's about it! We wrap up our function, and we're done! + * @until } + */ |