Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Issue 5905064: Watcher package as base for all state watcher. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 8 months ago by TheMue
Modified:
13 years, 8 months ago
Reviewers:
niemeyer, mp+99330
Visibility:
Public.

Description

Watcher package as base for all state watcher. Like the presence package observing the presence of a ZooKeeper node the Watcher can be configured to observe content or children changes of nodes. Those changes are continuously delivered until the Watcher is stopped. https://code.launchpad.net/~themue/juju/go-state-watcher/+merge/99330 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 18

Patch Set 2 : Watcher package as base for all state watcher. #

Total comments: 24

Patch Set 3 : Watcher package as base for all state watcher. #

Patch Set 4 : Watcher package as base for all state watcher. #

Total comments: 34

Patch Set 5 : Watcher package as base for all state watcher. #

Total comments: 24

Patch Set 6 : Watcher package as base for all state watcher. #

Patch Set 7 : Watcher package as base for all state watcher. #

Total comments: 4

Patch Set 8 : Watcher package as base for all state watcher. #

Total comments: 8

Patch Set 9 : Watcher package as base for all state watcher. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+384 lines, -0 lines) Patch
A [revision details] View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
A state/watcher/watcher.go View 1 2 3 4 5 6 7 1 chunk +208 lines, -0 lines 0 comments Download
A state/watcher/watcher_test.go View 1 2 3 4 5 6 7 8 1 chunk +174 lines, -0 lines 0 comments Download

Messages

Total messages: 24
TheMue
Please take a look.
13 years, 8 months ago (2012-03-26 13:37:07 UTC) #1
niemeyer
Going in a good direction. Main thing is to sort out the watcher type distinction, ...
13 years, 8 months ago (2012-03-26 21:06:38 UTC) #2
TheMue
Please take a look. https://codereview.appspot.com/5905064/diff/1/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/1/state/watcher/watcher.go#newcode1 state/watcher/watcher.go:1: // launchpad.net/juju/state/watcher On 2012/03/26 21:06:38, ...
13 years, 8 months ago (2012-03-27 14:30:55 UTC) #3
TheMue
PTAL https://codereview.appspot.com/5905064/diff/1/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/1/state/watcher/watcher.go#newcode47 state/watcher/watcher.go:47: // containing the node content as first element ...
13 years, 8 months ago (2012-03-27 14:37:49 UTC) #4
rog
LGTM with a couple of minors. https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher.go#newcode49 state/watcher/watcher.go:49: watch := func() ...
13 years, 8 months ago (2012-03-27 15:09:53 UTC) #5
rog
https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher_test.go File state/watcher/watcher_test.go (right): https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher_test.go#newcode15 state/watcher/watcher_test.go:15: // wrapper shows the returning of user defined types ...
13 years, 8 months ago (2012-03-27 16:22:24 UTC) #6
TheMue
Please take a look. https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher_test.go File state/watcher/watcher_test.go (right): https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher_test.go#newcode15 state/watcher/watcher_test.go:15: // wrapper shows the returning ...
13 years, 8 months ago (2012-03-27 17:05:44 UTC) #7
TheMue
Please take a look. https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher.go#newcode49 state/watcher/watcher.go:49: watch := func() <-chan zookeeper.Event ...
13 years, 8 months ago (2012-03-27 17:12:19 UTC) #8
TheMue
PTAL https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/5001/state/watcher/watcher.go#newcode176 state/watcher/watcher.go:176: diff := make(map[string]bool) On 2012/03/27 15:09:54, rog wrote: ...
13 years, 8 months ago (2012-03-27 17:12:48 UTC) #9
niemeyer
I think this is still going in a positive direction, but unfortunately I'll have to ...
13 years, 8 months ago (2012-03-28 00:28:59 UTC) #10
TheMue
Please take a look. https://codereview.appspot.com/5905064/diff/13001/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/13001/state/watcher/watcher.go#newcode11 state/watcher/watcher.go:11: // updates individually. On 2012/03/28 ...
13 years, 8 months ago (2012-03-28 11:12:56 UTC) #11
rog
looking good. mostly minors. https://codereview.appspot.com/5905064/diff/13005/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/13005/state/watcher/watcher.go#newcode20 state/watcher/watcher.go:20: func NewContentWatcher(zk *zookeeper.Conn, path string) ...
13 years, 8 months ago (2012-03-28 12:10:59 UTC) #12
TheMue
Please take a look. https://codereview.appspot.com/5905064/diff/13005/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/13005/state/watcher/watcher.go#newcode20 state/watcher/watcher.go:20: func NewContentWatcher(zk *zookeeper.Conn, path string) ...
13 years, 8 months ago (2012-03-28 12:42:56 UTC) #13
TheMue
Please take a look.
13 years, 8 months ago (2012-03-28 13:10:46 UTC) #14
rog
LGTM https://codereview.appspot.com/5905064/diff/12007/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/12007/state/watcher/watcher.go#newcode76 state/watcher/watcher.go:76: // channel. It returns the next watch if ...
13 years, 8 months ago (2012-03-28 13:36:08 UTC) #15
TheMue
Please take a look.
13 years, 8 months ago (2012-03-28 13:44:10 UTC) #16
TheMue
PTAL https://codereview.appspot.com/5905064/diff/12007/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/12007/state/watcher/watcher.go#newcode76 state/watcher/watcher.go:76: // channel. It returns the next watch if ...
13 years, 8 months ago (2012-03-28 13:46:43 UTC) #17
niemeyer
LGTM, with the following trivial. Thanks for all the changes Frank. This is nice. https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go ...
13 years, 8 months ago (2012-03-28 20:08:42 UTC) #18
rog
https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go#newcode52 state/watcher/watcher.go:52: if watch == nil { On 2012/03/28 20:08:42, niemeyer ...
13 years, 8 months ago (2012-03-28 21:27:56 UTC) #19
niemeyer
https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go#newcode52 state/watcher/watcher.go:52: if watch == nil { On 2012/03/28 21:27:56, rog ...
13 years, 8 months ago (2012-03-29 02:45:37 UTC) #20
niemeyer
Btw, Frank, this is still good to go right now. Any changes may be done ...
13 years, 8 months ago (2012-03-29 03:49:34 UTC) #21
rog
https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go File state/watcher/watcher.go (right): https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go#newcode52 state/watcher/watcher.go:52: if watch == nil { On 2012/03/29 02:45:38, niemeyer ...
13 years, 8 months ago (2012-03-29 10:02:44 UTC) #22
TheMue
*** Submitted: Watcher package as base for all state watcher. Like the presence package observing ...
13 years, 8 months ago (2012-03-29 12:46:44 UTC) #23
niemeyer
13 years, 8 months ago (2012-03-29 14:23:33 UTC) #24
https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go
File state/watcher/watcher.go (right):

https://codereview.appspot.com/5905064/diff/12009/state/watcher/watcher.go#ne...
state/watcher/watcher.go:52: if watch == nil {
On 2012/03/29 10:02:44, rog wrote:
> i still think that we've got a very good way to say "no error" - it's nil.

That's the crux. There's an error. This is the purpose of update:

// update retrieves the node content and emits it to the change
// channel if it has changed. It returns the next watch.

Has the node been emitted to the change channel? No. Has the next watch been
returned? No. This is very clearly an exceptional situation that interrupted the
normal flow of the function. The way to say that in Go is to return an error.
What's the error? The tomb is in a dying state. tomb.Dying.

I've experienced the use of a nil err in exactly that situation in larger scale,
with the pattern you're suggesting, and it goes bad. It breaks completely the
convention people are used to, and the code becomes brittle and hard to follow.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b