[CDRIVER-212] Connection Pool Created: 04/May/13  Updated: 11/Nov/13  Resolved: 11/Nov/13

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.90.0

Type: New Feature Priority: Major - P3
Reporter: Rock Li Assignee: Gary Murakami
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible

 Description   

What about to add the connection pool in the c driver?

Sample codes:

mongo_conn_pool *pool = mongo_conn_pool_alloc();
mongo_conn_pool_init(pool, options);
mongo *conn = mongo_conn_pool_acquire(pool);
/* ..... */
mongo_conn_pool_release(pool);
mongo_conn_pool_destroy(pool);
mongo_conn_pool_dealloc(pool);

Does anyone think this make sense?



 Comments   
Comment by Christian Hergert [ 11/Nov/13 ]

Hi,

The new C driver[1] can do connection pooling (however we pool at the client level).

You can use it like:

mongoc_client_pool_t *pool;
mongoc_client_t *client;
mongoc_uri_t *uri;
 
uri = mongoc_uri_new("mongodb://127.0.0.1?maxpoolsize=1&minpoolsize=1");
pool = mongoc_client_pool_new(uri);
 
/* inside of a pthread */
client = mongoc_client_pool_pop(pool);
/* Do your work here. */
mongoc_client_pool_push(pool, client);
 
mongoc_uri_destroy(uri);
mongoc_client_pool_destroy(pool);

[1] https://github.com/chergert/libmongoc/

Generated at Wed Feb 07 21:08:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.