You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Piotr Bzdyl <pi...@bzdyl.net> on 2013/01/02 14:26:20 UTC
Async operations callbacks support
Hello,
I started looking at the LDAP Client API and noticed that is doesn't
support callbacks on the futures returned by various
LdapAsyncConnection methods.
Was it considered to add such callbacks? It could be easily
implemented by extending ListenableFuture from Guava library instead
of implementing bare j.u.c.Future. All implementing classes (e.g.
AddFuture) could be implemented by extending SettableFuture so it
shouldn't involve much coding.
Best regards,
Piotr
Re: Async operations callbacks support
Posted by Piotr Bzdyl <pi...@bzdyl.net>.
Does it mean you don't mind adding Guava as a dependency? Usage of
Future with callbacks would be the most flexible and with minimal
changes in the code.
If there is no objection, I can create a patch and submit it in JIRA issue.
Best regards,
Piotr
On Wed, Jan 2, 2013 at 3:01 PM, Emmanuel Lécharny <el...@gmail.com> wrote:
> Le 1/2/13 2:26 PM, Piotr Bzdyl a écrit :
>> Hello,
>>
>> I started looking at the LDAP Client API and noticed that is doesn't
>> support callbacks on the futures returned by various
>> LdapAsyncConnection methods.
>>
>> Was it considered to add such callbacks? It could be easily
>> implemented by extending ListenableFuture from Guava library instead
>> of implementing bare j.u.c.Future. All implementing classes (e.g.
>> AddFuture) could be implemented by extending SettableFuture so it
>> shouldn't involve much coding.
>
> That's an interesting question. Currently, we assumed that we get back a
> Future, and the client is responsible to call it when it needs some
> result. Most of the time, it's just cosmetic, as you should get the
> result immediately, except for requests like Search, Persistent Search
> and Replication.
>
> But in some case, it could be interesting not to block on a
> Future.get(), but to pass a callback which gets executed when the
> response arrives. It should be a minor extensio to the existing API. We
> can even do that without any Future : something like void search(
> Callback callback, Dn baseDn, String filter, SearchScope scope,
> String... attributes ).
>
> We welcome any patch :)
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
Re: Async operations callbacks support
Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 1/2/13 3:18 PM, Piotr Bzdyl a écrit :
> That would mean implementing and maintaining Futures supporting
> callback when we have such implementation available from Guava. Are
> you sure it's a better way to add support for callbacks?
Using another dependency is problematic, especially Guava. The policy
that rules Guava is totally opaque, nobody can propose patches that get
committed (https://plus.google.com/113026104107031516488/posts/ZRdtjTL1MpM).
Plus, I don't think it's necessary to add an extra layer, when we can
just inject a callback into the async method call, which is probably
simpler than injecting the callback in a Future. But you can do both :
injecting the callback into the method call, or into the Future.
In other words, using Guava seems a bit too heavy...
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com
Re: Async operations callbacks support
Posted by Piotr Bzdyl <pi...@bzdyl.net>.
That would mean implementing and maintaining Futures supporting
callback when we have such implementation available from Guava. Are
you sure it's a better way to add support for callbacks?
Best regards,
Piotr
On Wed, Jan 2, 2013 at 3:04 PM, Kiran Ayyagari <ka...@apache.org> wrote:
> and at the same time no dependency on another lib (guava etc.) please
>
> On Wed, Jan 2, 2013 at 7:31 PM, Emmanuel Lécharny <el...@gmail.com>wrote:
>
>> Le 1/2/13 2:26 PM, Piotr Bzdyl a écrit :
>> > Hello,
>> >
>> > I started looking at the LDAP Client API and noticed that is doesn't
>> > support callbacks on the futures returned by various
>> > LdapAsyncConnection methods.
>> >
>> > Was it considered to add such callbacks? It could be easily
>> > implemented by extending ListenableFuture from Guava library instead
>> > of implementing bare j.u.c.Future. All implementing classes (e.g.
>> > AddFuture) could be implemented by extending SettableFuture so it
>> > shouldn't involve much coding.
>>
>> That's an interesting question. Currently, we assumed that we get back a
>> Future, and the client is responsible to call it when it needs some
>> result. Most of the time, it's just cosmetic, as you should get the
>> result immediately, except for requests like Search, Persistent Search
>> and Replication.
>>
>> But in some case, it could be interesting not to block on a
>> Future.get(), but to pass a callback which gets executed when the
>> response arrives. It should be a minor extensio to the existing API. We
>> can even do that without any Future : something like void search(
>> Callback callback, Dn baseDn, String filter, SearchScope scope,
>> String... attributes ).
>>
>> We welcome any patch :)
>>
>> --
>> Regards,
>> Cordialement,
>> Emmanuel Lécharny
>> www.iktek.com
>>
>>
>
>
> --
> Kiran Ayyagari
> http://keydap.com
Re: Async operations callbacks support
Posted by Kiran Ayyagari <ka...@apache.org>.
and at the same time no dependency on another lib (guava etc.) please
On Wed, Jan 2, 2013 at 7:31 PM, Emmanuel Lécharny <el...@gmail.com>wrote:
> Le 1/2/13 2:26 PM, Piotr Bzdyl a écrit :
> > Hello,
> >
> > I started looking at the LDAP Client API and noticed that is doesn't
> > support callbacks on the futures returned by various
> > LdapAsyncConnection methods.
> >
> > Was it considered to add such callbacks? It could be easily
> > implemented by extending ListenableFuture from Guava library instead
> > of implementing bare j.u.c.Future. All implementing classes (e.g.
> > AddFuture) could be implemented by extending SettableFuture so it
> > shouldn't involve much coding.
>
> That's an interesting question. Currently, we assumed that we get back a
> Future, and the client is responsible to call it when it needs some
> result. Most of the time, it's just cosmetic, as you should get the
> result immediately, except for requests like Search, Persistent Search
> and Replication.
>
> But in some case, it could be interesting not to block on a
> Future.get(), but to pass a callback which gets executed when the
> response arrives. It should be a minor extensio to the existing API. We
> can even do that without any Future : something like void search(
> Callback callback, Dn baseDn, String filter, SearchScope scope,
> String... attributes ).
>
> We welcome any patch :)
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>
--
Kiran Ayyagari
http://keydap.com
Re: Async operations callbacks support
Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 1/2/13 2:26 PM, Piotr Bzdyl a écrit :
> Hello,
>
> I started looking at the LDAP Client API and noticed that is doesn't
> support callbacks on the futures returned by various
> LdapAsyncConnection methods.
>
> Was it considered to add such callbacks? It could be easily
> implemented by extending ListenableFuture from Guava library instead
> of implementing bare j.u.c.Future. All implementing classes (e.g.
> AddFuture) could be implemented by extending SettableFuture so it
> shouldn't involve much coding.
That's an interesting question. Currently, we assumed that we get back a
Future, and the client is responsible to call it when it needs some
result. Most of the time, it's just cosmetic, as you should get the
result immediately, except for requests like Search, Persistent Search
and Replication.
But in some case, it could be interesting not to block on a
Future.get(), but to pass a callback which gets executed when the
response arrives. It should be a minor extensio to the existing API. We
can even do that without any Future : something like void search(
Callback callback, Dn baseDn, String filter, SearchScope scope,
String... attributes ).
We welcome any patch :)
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com