inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
226 stars 39 forks source link

Long-lived connection #80

Closed SteelAlloy closed 2 years ago

SteelAlloy commented 2 years ago

In the javascript world I was using ldapjs which has a reconnect option.

Would it be possible to reproduce a similar feature, that is to say to have a long-lived connection that reconnects automatically when the connection is closed ?

I have very long connection time with my server, so it would reduce loading time a lot.

Thanks !

inejge commented 2 years ago

It's not something I would incorporate into the crate itself—too many configuration options, too much policy—but it should be possible to make a wrapper struct which would forward operations to an inner LDAP handle while also arranging some kind of signalling from the connection task (i.e., not simply using the drive! macro) to recognize connection shutdown and attempt reconnection.

SteelAlloy commented 2 years ago

I think it would indeed not fit in the crate, but a piece of code to do this based on the library would be very useful. I'll try to do this myself, but I'm a novice with Rust. If you have some tracks, or a skeleton of code I'll take it !

What seems to me the most complex is the signal system

inejge commented 2 years ago

For signalling, you can see how it's done between an Ldap handle and its connection in src/conn.rs and src/ldap.rs. TLDR: it's a bunch of oneshot and mpsc channels, plus Tokio's select!.

inejge commented 2 years ago

Since this is a usage issue, or at best an enhancement proposal which would be a WONTFIX for the reasons stated above, I'll close the issue. It can be reopened if necessary.