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

Service Discovery support for etcd v3 #663

Merged
merged 2 commits into from
Feb 15, 2018
Merged

Service Discovery support for etcd v3 #663

merged 2 commits into from
Feb 15, 2018

Conversation

cabrel
Copy link
Contributor

@cabrel cabrel commented Feb 8, 2018

This adds a go-kit/kit/sd implementation for etcd/clientv3, which was requested in #505

All tests except the client_test were ported over which I had to remove because they are more problematic with regards to etcd v3. The etcd maintainers switched to protobufs in v3 and placed those generated messages under internal/, which would cause issues trying to reference it (see https://golang.org/s/go14internal), this makes stubbing clientv3.KV more difficult without burying the
implementation behind interfaces to remove the direct dependence on those internal packages.

Features in use with v3:

  • Support for etcd/clientv3.Watcher
  • Support for etcd/clientv3.Lease (TTL)
  • Username/password support

This adds a go-kit/kit/sd implementation for etcd/clientv3. All tests except the
client_test were ported over.

I have removed the client tests because they are
more problematic with regards to etcd v3. The etcd maintainers
switched to protobufs in v3 and placed those generated messages under
internal/, which would cause issues trying to reference it
(see https://golang.org/s/go14internal).
This makes stubbing clientv3.KV more difficult without burying the
implementation behind interfaces to remove the direct dependence
on those internal packages.

Features in use with v3:
- Support for etcd/clientv3.Watcher
- Support for etcd/clientv3.Lease (TTL)
- Username/password support
@peterbourgon
Copy link
Member

Very cool! I'll give this a review in the next day or two. Thanks!

Copy link
Member

@peterbourgon peterbourgon left a comment

Choose a reason for hiding this comment

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

A few minor changes but this looks good! Thanks especially for the work on the tests!

// ErrNoValue indicates a client method needs a value but receives none.
ErrNoValue = errors.New("no value provided")

ErrKeyNotFound = errors.New("requested key not found")
Copy link
Member

Choose a reason for hiding this comment

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

Small comment please :)

c.wcf()
}
return nil
}
Copy link
Member

Choose a reason for hiding this comment

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

Does this function need to return an error?

@@ -0,0 +1 @@
package etcdv3
Copy link
Member

Choose a reason for hiding this comment

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

One or two sentences of doc comment would be appreciated!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied and updated the doc comment from sd/etcd to sd/etcdv3 for consistency sake.

// return
// }
// }
// }
Copy link
Member

Choose a reason for hiding this comment

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

Dead code?

func (tc *testClient) CancelWatch() {}

func (tc *testClient) WatchPrefix(prefix string, ch chan struct{}) {
}
Copy link
Member

Choose a reason for hiding this comment

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

Newline.

{errors.New("regError"), "key=testKey value=testValue err=regError\n"},
// test case: registration successful
{nil, "key=testKey value=testValue action=register\n"},
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you define this in the test function rather than in the global scope?

{errors.New("deregError"), "key=testKey value=testValue err=deregError\n"},
// test case: deregistration successful
{nil, "key=testKey value=testValue action=deregister\n"},
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you define this in the test function rather than in the global scope?

- moved global structs inside of test functions since they are not used
  anywhere else
- moved unused Err variable
- removed error return type from close()
- added doc comment
@peterbourgon
Copy link
Member

Thank you very much!

@peterbourgon peterbourgon merged commit 286fe7a into go-kit:master Feb 15, 2018
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.

2 participants