Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncRequestID does not provide a useful async semantic #137

Open
chibenwa opened this issue Dec 3, 2022 · 1 comment
Open

AsyncRequestID does not provide a useful async semantic #137

chibenwa opened this issue Dec 3, 2022 · 1 comment

Comments

@chibenwa
Copy link

chibenwa commented Dec 3, 2022

The asynchronous tooling in unboundId allows starting an asynchronous computation but to get it's result I am forced to get() it, which essentially forces to block until it completes. (JDK futures are typically falling into this pitfall, more expressive models like CompletabeFutures or Guava's Futures do not.)

This makes integration with non-blocking code really painfull. Eg reactor library.

A simple enhancement would be to add a system of callbacks enabling people to register actions to be performed upon receiving the response. I did a similar contributing on imapNio: yahoo/imapnio#118

Ultimately, this would allow me to refactor part of the James code and leverage non blocking code on top of the LDAP / authentication layers. Which could be a big win.

Would there be interest for this in the community?

@dirmgr
Copy link
Collaborator

dirmgr commented Dec 6, 2022

Sorry for not getting to this earlier. However, I do believe that the LDAP SDK's asynchronous processing support already does what you're asking for.

For example, if you want to process an add operation asynchronously, then you can call LDAPConnection.asyncAdd(AddRequest,AsyncResultListener). If the provided AsyncResultListener is non-null, then when the LDAP SDK receives the response to the request, it will call the AsyncResultListener.ldapResultReceived method, and that's where you can do whatever processing you want for that result. You don't need to rely on the AsyncRequestID at all in that case (unless you want to abandon or cancel the operation).

This approach is available for add, compare, delete, modify, modify DN, and search operations. In the case of search operations, the search request needs to have been created with a constructor that uses a SearchResultListener, and that listener must be actually be an AsynchSearchResultListener, which provides methods that will be called for each entry and reference that is returned for the search, as well as for the final search done message.

We don't support asynchronous processing for for either bind or extended operations, and that is intentional. Bind operations must always be processed in isolation on a connection, so whenever a bind request is received on a connection, the server will stop working on any other operations in progress on that connection, and it won't allow any new requests on the connection until the bind is done. Similarly, some types of extended operations (for example, StartTLS) also need to be processed in isolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants