Closed t2y closed 1 year ago
I agree with conn.SearchAsync(...)
API design when we provide a more robust and extendable API. I will change the API signature when other reviewers want.
I found conn.SearchAsync(...)
API also suggested on #341. So I can merge some requirements if they are needed.
@cpuschma I implemented asynchronous search for v3 only (a9daeeb) as a basis for discussion. I hope it's helpful to discuss the design we require.
How do we get a consensus asynchronous search design to move this PR forward?
Thanks for the updates @t2y
I'm also skeptical of exposing an internally created channel on the public API of the library.
I'd like feedback from others too though @go-ldap/committers
@johnweldon Thank you for reviewing. I also added conn.SearchAsync(...)
API as a reference implementation. Tell me if you have a good idea.
SearchAsync(ctx context.Context, searchRequest *SearchRequest, bufferSize int) Response
type Response interface {
Entry() *Entry
Referral() string
Controls() []Control
Err() error
Next() bool
}
As stated in my review, I would go for the design similar to the sql.Rows
interface of the official sql library. It would allow us to keep the internals, which makes changes easier. I think an interface like t2ys one is sufficient
type Response interface {
Entry() *Entry
Referral() string
Controls() []Control
Err() error
Next() bool
}
We have three options now.
At the current moment, we're considering No.2 (only SearchAsync()) as better, right?
Agreed; I vote no.2 as the preferred choice.
@cpuschma @stefanmcshane @vetinari What do you think above three options? I think No. 2 is better, too.
Sorry I'm currently sick. I would also go for Option 2 with the SQL like syntax
Thanks for the comments. I'm going to update the implementation to provide No.2 only.
Got race condition with go 1.16.x.
github.com/go-ldap/ldap.(*Conn).GetLastError()
/home/runner/work/ldap/ldap/conn.go:330 +0x204
--- FAIL: TestSearchAsyncAndCancel (0.06s)
ldap_test.go:411: TestSearchAsyncAndCancel: (&(objectclass=rfc822mailgroup)(cn=*Computer*)) -> num of entries = 11
testing.go:1102: race detected during execution of test
https://github.com/go-ldap/ldap/actions/runs/5340457447/jobs/9680294821
@cpuschma @johnweldon @stefanmcshane @vetinari I cleaned up this PR to provide SearchAsync() only. Could you review it?
I did check the source during lunchtime. LGTM so far, I'll run a few tests later and give you feedback as soon as I'm finished
I'll prepare a pre-release for people to test the new feature
After I discussed with @cpuschma and @johnweldon, we decided to provide a search asynchronous function.
This PR is inspired by #319, I appreciate @stefanmcshane.
319 is a draft, and it seems there is no activity now. So, I recreated the functionality with the addition of my idea.
This PR is different from #319. I describe them below.
I'm new to LDAP protocol, so any comments are welcome.
References
135
422
341