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

*: combine Watch, WatchPrefix with variadic function #4602

Merged
merged 3 commits into from
Feb 24, 2016

Conversation

gyuho
Copy link
Contributor

@gyuho gyuho commented Feb 24, 2016

For #4598.

rev int64

// for watch
prefix string
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should use end instead of having a separate prefix field; watch can check the op for if end == nil || deepEqual(end, expectedPrefix) and throw an error if it's something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh ok. Will fix. Thanks!

@gyuho gyuho force-pushed the watch_option branch 5 times, most recently from 93aa1e6 to e95295d Compare February 24, 2016 03:20
@gyuho
Copy link
Contributor Author

gyuho commented Feb 24, 2016

/cc @heyitsanthony @xiang90 PTAL.

  1. used tRange instead of tWatch
  2. document what OpOption can be passed to Watch

Thanks!

func opWatch(key string, opts ...OpOption) Op {
ret := Op{t: tRange, key: []byte(key)}
ret.applyOpts(opts)
switch {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you pull getPrefix([]byte) []byte out of WithPrefix() so this can check
case ret.end != nil && reflect.DeepEqual(end, getPrefix(ret.key)): panic("only supports single keys or prefixes")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Will add that. Thanks.

@heyitsanthony
Copy link
Contributor

lgtm aside from the missing prefix checking, thanks!

@gyuho
Copy link
Contributor Author

gyuho commented Feb 24, 2016

@heyitsanthony Just added that function and check. Thanks! Will merge after green lights.

@gyuho
Copy link
Contributor Author

gyuho commented Feb 24, 2016

test failed. will take a look.

ret.applyOpts(opts)
switch {
case ret.end != nil && !reflect.DeepEqual(ret.end, getPrefix(ret.key)):
panic("only supports single keys or prefixes")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@heyitsanthony Could you check this part? ret.end != nil && !reflect.DeepEqual(ret.end, getPrefix(ret.key))?

So if someone specifies WithPrefix in Watch api, end will be non nil. And it should be equal to getPrefix(ret.key). So I think it should be !reflect.DeepEqual(ret.end, getPrefix(ret.key)), not reflect.DeepEqual(ret.end, getPrefix(ret.key)). Test failed with case ret.end != nil && reflect.DeepEqual(end, getPrefix(ret.key)).

Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, you're right. I accidentally dropped the !.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Merging since tests passed.

gyuho added a commit that referenced this pull request Feb 24, 2016
*: combine Watch, WatchPrefix with variadic function
@gyuho gyuho merged commit 783e6f6 into etcd-io:master Feb 24, 2016
@gyuho gyuho deleted the watch_option branch February 24, 2016 04:26
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.

3 participants