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

allow all options of HTTPPool to be specified by users #33

Merged
merged 1 commit into from
Oct 20, 2014
Merged

allow all options of HTTPPool to be specified by users #33

merged 1 commit into from
Oct 20, 2014

Conversation

fumin
Copy link
Contributor

@fumin fumin commented Oct 1, 2014

The default constructor NewHTTPPool is making too many assumptions about how people would use the library. For example, for security purpose I'd want groupcache to listen on a different port by calling Handle on a different ServeMux other than the http.DefaultServeMux. Others have also requested to be able to specify the basePath perhaps to shorter paths for performance reasons #22 ?

@dvirsky
Copy link

dvirsky commented Oct 1, 2014

In a recent discussion about the replica number, @nf suggested a configuration struct that will be passed to the http pool. See #29 (comment)
I think it's a better approach.

@fumin
Copy link
Contributor Author

fumin commented Oct 1, 2014

Right, it's indeed a cleaner approach, thanks for the pointer. I have refactored this change to encapsulate all options to HTTPPool in the type HTTPPoolOptions.

@dvirsky
Copy link

dvirsky commented Oct 3, 2014

looks good IMO

@fumin
Copy link
Contributor Author

fumin commented Oct 16, 2014

Hi, @nf do you think this change makes sense in light of the suggestion you made in #29 (comment) ? With a couple of other changes, we are deviating further and further away from this main repo, which is not good. It'd be great if you could review this change to help us be closer to this main repo. Sorry to be possibly disturbing you and thanks in advance.


// ServeMux specifies the request multiplexer to be registered
// If blank, it defaults to http.DefaultServeMux.
ServeMux *http.ServeMux
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems redundant, we should just return the pool and allow the user to register it where they want.

@fumin
Copy link
Contributor Author

fumin commented Oct 20, 2014

Right, registering an HTTPPool with a http.ServeMux should not be the responsibility of NewHTTPPoolOpts. I have refactored the code to make this the case. Thanks for seeing this.

// It registers itself as a PeerPicker and as an HTTP handler with the
// http.DefaultServeMux.
// NewHTTPPool initializes an HTTP pool of peers, and registers itself as a PeerPicker.
// For backwards compatibility, it also registers itself as an http.Handler with http.DefaultServeMux.
Copy link
Contributor

Choose a reason for hiding this comment

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

"For convenience, ..."

@fumin
Copy link
Contributor Author

fumin commented Oct 20, 2014

I had a hard time describing the need for users to register the pool with a http.ServeMux. Fortunately, now it sounds clearer and more native. Thanks!

@adg
Copy link
Contributor

adg commented Oct 20, 2014

I'd also like you to squash these commits into one, if you please.

@fumin
Copy link
Contributor Author

fumin commented Oct 20, 2014

Sure, of course. However, as I actually haven't squashed commits before, I wonder are you able to confirm this is correct:

  • Run git rebase -i locally.
  • Run git push --force origin master to push it to github.

I am aware that this alters the history on the server, and thus am not sure is this correct?

@adg
Copy link
Contributor

adg commented Oct 20, 2014

That should work, but instead of git rebase you could run:

git checkout 734128ad35f3e3aed464bd12b1319332b18c56e1

to return to the first commit in the sequence, with all your changes unstaged. Then git add the changed files. Then run git commit --amend to update that first commit. Finally then you can git push --force.

@fumin
Copy link
Contributor Author

fumin commented Oct 20, 2014

Thanks for the instructions, they work nicely. The commits are now cleanly squashed into one.

@adg
Copy link
Contributor

adg commented Oct 20, 2014

Could you please sign the Google CLA? Thanks.

@fumin
Copy link
Contributor Author

fumin commented Oct 20, 2014

Yes, sure, I have signed it and submitted the CLA.

On Mon, Oct 20, 2014 at 3:29 PM, Andrew Gerrand [email protected]
wrote:

Could you please sign the Google CLA
https://cla.developers.google.com/about/google-individual? Thanks.


Reply to this email directly or view it on GitHub
#33 (comment).

adg added a commit that referenced this pull request Oct 20, 2014
allow all options of HTTPPool to be specified by users
@adg adg merged commit d2a1805 into golang:master Oct 20, 2014
@adg
Copy link
Contributor

adg commented Oct 20, 2014

Thanks!

@fumin
Copy link
Contributor Author

fumin commented Oct 20, 2014

No problem, thanks for all the great comments, too.

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