-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
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
Very cool! I'll give this a review in the next day or two. Thanks! |
There was a problem hiding this 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!
sd/etcdv3/client.go
Outdated
// ErrNoValue indicates a client method needs a value but receives none. | ||
ErrNoValue = errors.New("no value provided") | ||
|
||
ErrKeyNotFound = errors.New("requested key not found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment please :)
sd/etcdv3/client.go
Outdated
c.wcf() | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
sd/etcdv3/registrar.go
Outdated
// return | ||
// } | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code?
sd/etcdv3/registrar_test.go
Outdated
func (tc *testClient) CancelWatch() {} | ||
|
||
func (tc *testClient) WatchPrefix(prefix string, ch chan struct{}) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline.
sd/etcdv3/registrar_test.go
Outdated
{errors.New("regError"), "key=testKey value=testValue err=regError\n"}, | ||
// test case: registration successful | ||
{nil, "key=testKey value=testValue action=register\n"}, | ||
} |
There was a problem hiding this comment.
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?
sd/etcdv3/registrar_test.go
Outdated
{errors.New("deregError"), "key=testKey value=testValue err=deregError\n"}, | ||
// test case: deregistration successful | ||
{nil, "key=testKey value=testValue action=deregister\n"}, | ||
} |
There was a problem hiding this comment.
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
Thank you very much! |
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: