noirello / bonsai

Simple Python 3 module for LDAP, using libldap2 and winldap C libraries.
MIT License
117 stars 33 forks source link

Question: Connection Pooling #23

Closed schlitzered closed 5 years ago

schlitzered commented 5 years ago

is there a connection pool in place, or do i have to build my own connection pool on top of this library?

noirello commented 5 years ago

No, there isn't, sorry. You have to build your own. But a contribution about this would be much appreciated. :)

schlitzered commented 5 years ago

i take a look.

i guess the easiest thing would be to implement the connection pool directly in LDAPClient.

i think of adding a new parameter to init that will be called pool_size.

i will then add a acquire and release function, that can be used to get & return LDAPConnection objects.

i would also implement enter and exit functions, so LDAPClient can be used as a context manager.

what do you think?

noirello commented 5 years ago

I think a separate ConnectionPool class and a get_connection_pool or create_connection_pool method on LDAPClient would be better, easier to maintain. Also different connection types (async, gevent, etc.) probably will require slightly different pool implementations, so a base class that can be used for inheriting would be beneficial. The context manager (on the ConnectionPool class) is a great idea.

noirello commented 5 years ago

I know, quite some time has passed, but I've added some connection pool classes that are currently on the feature/pool branch. I'm planning to include these modifications in the next release (that'll happen in a few days with some luck). If you have any thoughts about it, please share them.

noirello commented 5 years ago

Basic pool functionality is available now in 1.1.0.