8000 Tolerate existing paging control in SearchWithPaging by stevekuznetsov · Pull Request #51 · go-ldap/ldap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Tolerate existing paging control in SearchWithPaging #51

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

Merged
merged 1 commit into from
Feb 16, 2016

Conversation

stevekuznetsov
Copy link
Contributor

With the current implementation of Search, our interaction with this library has been as such:

  • gather knowledge in order to fully qualify an LDAP query
  • create a SearchRequest
  • get a SearchResponse
  • unpack the response for salient information

The current API for SearchWithPaging does not honor this workflow and expects something other than a fully-qualified SearchRequest to function. This PR adds another API call that allows for a fully qualified search request to be all that is necessary to issue a request to search with client-side page stitching.

@johnweldon @liggitt PTAL

@@ -268,6 +268,9 @@ func NewSearchRequest(
}
}

// SearchWithPaging augments the given search request with a paging control containing the given paging size, then
// issues a search with buffered paging using the request. All paged responses are buffered so that the result can
// be returned atomically.
func (l *Conn) SearchWithPaging(searchRequest *SearchRequest, pagingSize uint32) (*SearchResult, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is really doing two things:

  1. adding the paging control (which is easy to do yourself, and depending on the calling code, you might want to do yourself. I'd even consider requiring it in a future major version and removing the pagingSize param from here... not a huge fan of mutating the SearchRequest inside the function)
  2. searching/paging/appending (which is hard to do yourself)

What if we made SearchWithPaging tolerate a searchRequest that already had a matching ControlTypePaging control? That would let us avoid expanding the interface surface area

cases:

  • ControlTypePaging control missing, adds one matching pagingSize (current behavior)
  • ControlTypePaging control present but not actually a *ControlPaging, returns error
  • ControlTypePaging control present and matching pagingSize, no-op (would enable your use case)
  • ControlTypePaging control present but not matching pagingSize, returns error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would I pass through in the third case? SearchWithPaging(mySearchRequest, someIgnoredInt) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'd pass a pageSize that matched the already-present control's PagedSize

@stevekuznetsov stevekuznetsov force-pushed the skuznets/paging branch 2 times, most recently from 803d130 to 907411e Compare February 15, 2016 20:48
@stevekuznetsov
Copy link
Contributor Author

@liggitt Changed SearchWithPaging to have the desired function and added some tests.

@liggitt
Copy link
Contributor
liggitt commented Feb 15, 2016

LGTM. @johnweldon, any feedback on tolerating an already-present paging control like this?

Copy link
Member

Looks like a nice improvement, and low risk. LGTM :shipit:

@liggitt liggitt changed the title exposed better API for paged search Tolerate existing paging control in SearchWithPaging Feb 16, 2016
liggitt added a commit that referenced this pull request Feb 16, 2016
Tolerate existing paging control in SearchWithPaging
@liggitt liggitt merged commit 07a7330 into go-ldap:master Feb 16, 2016
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

Successfully merging this pull request may close these issues.

3 participants
0