libmongo-client 0.1.4
Functions
Mongo Sync Pool API
Mongo Sync API

These commands implement connection pooling over the mongo_sync family of commands. More...

Collaboration diagram for Mongo Sync Pool API:

Functions

mongo_sync_pool * mongo_sync_pool_new (const gchar *host, gint port, gint nmasters, gint nslaves)
 Create a new synchronous connection pool.
void mongo_sync_pool_free (mongo_sync_pool *pool)
 Close and free a synchronous connection pool.
mongo_sync_pool_connection * mongo_sync_pool_pick (mongo_sync_pool *pool, gboolean want_master)
 Pick a connection from a synchronous connection pool.
gboolean mongo_sync_pool_return (mongo_sync_pool *pool, mongo_sync_pool_connection *conn)
 Return a connection to the synchronous connection pool.

Detailed Description

These commands implement connection pooling over the mongo_sync family of commands.

Once a pool is set up, one can pick and return connections at one's leisure. Picking is done in a round-robin fashion (excluding connections that have been picked but not returned yet).


Function Documentation

void mongo_sync_pool_free ( mongo_sync_pool *  pool)

Close and free a synchronous connection pool.

Parameters:
poolis the pool to shut down.
Note:
The object will be freed, and shall not be used afterwards!

Definition at line 154 of file mongo-sync-pool.c.

Here is the call graph for this function:

mongo_sync_pool* mongo_sync_pool_new ( const gchar *  host,
gint  port,
gint  nmasters,
gint  nslaves 
)

Create a new synchronous connection pool.

Sets up a connection pool towards a given MongoDB server, and all its secondaries (if any).

Parameters:
hostis the address of the server.
portis the port to connect to.
nmastersis the number of connections to make towards the master.
nslavesis the number of connections to make towards the secondaries.
Note:
Either nmasters or nslaves can be zero, but not both at the same time.
The host MUST be a master, otherwise the function will return an error.
Returns:
A newly allocated mongo_sync_pool object, or NULL on error. It is the responsibility of the caller to close and free the pool when appropriate.

Definition at line 54 of file mongo-sync-pool.c.

Here is the call graph for this function:

mongo_sync_pool_connection* mongo_sync_pool_pick ( mongo_sync_pool *  pool,
gboolean  want_master 
)

Pick a connection from a synchronous connection pool.

Based on given preferences, selects a free connection object from the pool, and returns it.

Parameters:
poolis the pool to select from.
want_masterflags whether the caller wants a master connection, or secondaries are acceptable too.
Note:
For write operations, always select a master!
Returns:
A connection object from the pool.
Note:
The returned object can be safely casted to mongo_sync_connection, and passed to any of the mongo_sync family of commands. Do note however, that one shall not close or otherwise free a connection object returned by this function.

Definition at line 179 of file mongo-sync-pool.c.

gboolean mongo_sync_pool_return ( mongo_sync_pool *  pool,
mongo_sync_pool_connection *  conn 
)

Return a connection to the synchronous connection pool.

Once one is not using a connection anymore, it should be returned to the pool using this function.

Parameters:
poolis the pool to return to.
connis the connection to return.
Returns:
TRUE on success, FALSE otherwise.
Note:
The returned connection should not be used afterwards.

Definition at line 227 of file mongo-sync-pool.c.

 All Data Structures Files Functions Variables Enumerations Enumerator Defines