Merge lp://staging/~rogpeppe/gozk/comments-and-time into lp://staging/gozk/zookeeper
Proposed by
Roger Peppe
Status: | Merged |
---|---|
Merged at revision: | 26 |
Proposed branch: | lp://staging/~rogpeppe/gozk/comments-and-time |
Merge into: | lp://staging/gozk/zookeeper |
Diff against target: | 0 lines |
To merge this branch: | bzr merge lp://staging/~rogpeppe/gozk/comments-and-time |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
The Go Language Gophers | Pending | ||
Review via email: mp+92750@code.staging.launchpad.net |
Description of the change
Add some comments to Event and Stat types.
Also change Stat.CTime and Stat.MTime to return time.Time.
To post a comment you must log in.
Reviewers: mp+92750_ code.launchpad. net,
Message:
Please take a look.
Description:
Also change Stat.CTime and Stat.MTime to return time.Time.
https:/ /code.launchpad .net/~rogpeppe/ gozk/comments- and-time/ +merge/ 92750
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/5650075/
Affected files:
M zk.go
M zk_test.go
Index: zk.go
=== <email address hidden> >
<email address hidden>
=== modified file 'zk.go'
--- zk.go 2012-02-08 14:34:24 +0000
+++ zk.go 2012-02-13 12:38:16 +0000
@@ -92,8 +92,17 @@
// event.Type is set to EVENT_CLOSED and event.State is set to
STATE_CLOSED,
// to facilitate handling.
type Event struct {
- Type int
- Path string
+ // Type gives the type of event (one of the EVENT_* constants).
+ // If Type is EVENT_SESSION, then the event is a session
+ // event.
+ Type int
+
+ // For non-session events, Path gives the path of the node
+ // that was being watched.
+ Path string
+
+ // For session events, State (one of the STATE* constants) gives the
session
+ // status.
State int
}
@@ -304,46 +313,64 @@
c C.struct_Stat
}
+// Czxid returns the zxid of the change that caused the node to be created.
func (stat *Stat) Czxid() int64 {
return int64(stat.c.czxid)
}
+// Mzxid returns the zxid of the change that last modified the node.
func (stat *Stat) Mzxid() int64 {
return int64(stat.c.mzxid)
}
-func (stat *Stat) CTime() int64 { int64(stat. c.ctime) ) int64(stat. c.mtime) ) c.version)
- return int64(stat.c.ctime)
-}
-
-func (stat *Stat) MTime() int64 {
- return int64(stat.c.mtime)
-}
-
+func millisec2time(ms int64) time.Time {
+ return time.Unix(ms/1e3, ms%1e3*1e6)
+}
+
+// CTime returns the time (at millisecond resolution) when the node was
+// created.
+func (stat *Stat) CTime() time.Time {
+ return millisec2time(
+}
+
+// MTime returns the time (at millisecond resolution) when the node was
+// last modified.
+func (stat *Stat) MTime() time.Time {
+ return millisec2time(
+}
+
+// Version returns the number of changes to the data of the node.
func (stat *Stat) Version() int32 {
return int32(stat.
}
+// CVersion returns the number of changes to the children of the node. c.cversion)
func (stat *Stat) CVersion() int32 {
return int32(stat.
}
+// AVersion returns the number of changes to the ACL of the node. c.aversion)
func (stat *Stat) AVersion() int32 {
return int32(stat.
}
+// If the node is an ephemeral node, EphemeralOwner returns the session id c.ephemeralOwne r)
+// of the owner of the node; otherwise it will return zero.
func (stat *Stat) EphemeralOwner() int64 {
return int64(stat.
}
+// DataLength returns the length of the data in the node in bytes. c.dataLength)
func (stat *Stat) DataLength() int32 {
return int32(stat.
}
+// NumChildren returns the number of children of the znode. c.numChildren)
func (stat *Stat) NumChildren() int32 {
return int32(stat.
}
+// Pzxid returns the Pzxid of the node, whatever that is.
func (stat *Stat) Pzxid() int64 {
return int64(stat.c.pzxid)
}
Index: zk_test.go canonical. ...
=== roger.peppe@