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 peer provider plugins #156

Merged
merged 2 commits into from
Feb 23, 2017
Merged

Support peer provider plugins #156

merged 2 commits into from
Feb 23, 2017

Conversation

kriskowal
Copy link
Contributor

This change factors out a pluggable peer provider registry and extends the meaning of the -P flag to be a URI, currently only supporting the implicit or explicit file:/ protocol scheme.

@mention-bot
Copy link

@kriskowal, thanks for your PR! By analyzing the history of the files in this pull request, we identified @prashantv to be a potential reviewer.

@kriskowal
Copy link
Contributor Author

Fixes #155

RegisterPeerProvider("file", filePeerProvider{})
}

// Schemes returns supported peer provider protocol schemes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add unit tests in this package for:

  • registering a new scheme
  • making sure it's returned in Schemes
  • ensuring it's used when Resolve is called with that scheme

transport.go Outdated
// Paths are a strict subset of the URL file protocol scheme. We
// explicate the file protocol as a key into the peer provider
// registry.
if u.Scheme == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we register the file provider under the "" scheme and have this work without this if?

@@ -241,6 +242,13 @@ func parseDefaultConfigs(parser *flags.Parser) error {
}

func runWithOptions(opts Options, out output) {
if opts.TOpts.HostPortFile == "?" {
Copy link
Contributor

Choose a reason for hiding this comment

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

we can unit test this in, main_test.go has some integration tests that should have examples of how to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

Copy link
Contributor

@prashantv prashantv left a comment

Choose a reason for hiding this comment

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

lgtm

func TestResolveError(t *testing.T) {
oldRegistry := registry
defer func() { registry = oldRegistry }()
registry = make(map[string]PeerProvider)
Copy link
Contributor

Choose a reason for hiding this comment

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

optionally: make a helper for this,

func stubRegister() func() {
  oldRegistry := registry
  registry = make(map[string]PeerProvider)
  return func() { registry = oldRegistry }()
}

func TestResolveError(t *testing.T) {
  defer stubRegistry()()

  [...]
}

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

Successfully merging this pull request may close these issues.

None yet

3 participants