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

Support context.Context #326

Open
asuffield opened this issue Jun 14, 2021 · 8 comments
Open

Support context.Context #326

asuffield opened this issue Jun 14, 2021 · 8 comments

Comments

@asuffield
Copy link

This module currently lacks any support for context.Context, so it can't inherit conventional timeout and cancellation semantics. That seems worth adding.

@Adphi
Copy link

Adphi commented Oct 15, 2022

I have the beginning of a PR for context cancelation. One blocking point is the behavior on cancel. Should it become an abandon request? This one was not implemented here last time I checked.

@Joh4nnesHartl
Copy link

Definitely would be a nice feature, I am using context.Context almost everywhere and have some ugly wrapper around the ldap client. Support for it would be great.

@Joh4nnesHartl
Copy link

Joh4nnesHartl commented Nov 30, 2022

SUGGESTION:

How about enhancing the *ldap.Conn structure with new methods that end with WithContext to introduce conventional timeout & cancellation semantics to go-ldap.

Example:

// Add performs the given AddRequest
func (l *Conn) Add(addRequest *AddRequest) error

// AddWithContext performs the given AddRequest with a context, the context controls the entire lifetime of a request and its response
func (l *Conn) AddWithContext(ctx context.Context, addRequest *AddRequest) error



// Search performs the given search request
func (l *Conn) Search(searchRequest *SearchRequest) (*SearchResult, error)

// SearchWithContext performs the given search request with a context, the context controls the entire lifetime of a request and its response
func (l *Conn) SearchWithContext(ctx context.Context, searchRequest *SearchRequest) (*SearchResult, error)

...

This would ensure API compatability to the old methods and would not cause breaking changes for an upcoming patch like this. There would be another solution I thought of but it would introduce BREAKING CHANGES, which are most likely not wanted.

cc @Adphi @johnweldon @cpuschma

@johnweldon
Copy link
Member

How about enhancing the *ldap.Conn structure with new methods that end with WithContext to introduce conventional timeout & cancellation semantics to go-ldap.

I like this suggestion in principle. I'm unclear about actual implementation of the timeout and cancellation logic, but there should be ample examples and suggestions in other projects.

@asuffield
Copy link
Author

I'll knock out an attempt at an initial implementation

@Joh4nnesHartl
Copy link

I'll knock out an attempt at an initial implementation

I can join if you want 👍

@asuffield
Copy link
Author

Here's a first cut: #406

Not mirrored into v3 (yet), just bashing out what the basic API would look like. Probably still buggy.

@cpuschma
Copy link
Member

The same concept has been implemented by other libraries, each method has an equivalent with the option to provide a context.

I would follow the same scheme here

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

No branches or pull requests

5 participants