tokio_zookeeper/types/mod.rs
1mod acl;
2pub use self::acl::*;
3
4mod watch;
5pub use self::watch::*;
6
7mod multi;
8pub use self::multi::*;
9
10/// Statistics about a znode, similar to the UNIX `stat` structure.
11///
12/// # Time in ZooKeeper
13/// The concept of time is tricky in distributed systems. ZooKeeper keeps track of time in a number
14/// of ways.
15///
16/// - **zxid**: Every change to a ZooKeeper cluster receives a stamp in the form of a *zxid*
17/// (ZooKeeper Transaction ID). This exposes the total ordering of all changes to ZooKeeper. Each
18/// change will have a unique *zxid* -- if *zxid:a* is smaller than *zxid:b*, then the associated
19/// change to *zxid:a* happened before *zxid:b*.
20/// - **Version Numbers**: Every change to a znode will cause an increase to one of the version
21/// numbers of that node.
22/// - **Clock Time**: ZooKeeper does not use clock time to make decisions, but it uses it to put
23/// timestamps into the `Stat` structure.
24#[derive(Debug, PartialEq, Eq, Clone, Copy)]
25pub struct Stat {
26 /// The transaction ID that created the znode.
27 pub czxid: i64,
28 /// The last transaction that modified the znode.
29 pub mzxid: i64,
30 /// Milliseconds since epoch when the znode was created.
31 pub ctime: i64,
32 /// Milliseconds since epoch when the znode was last modified.
33 pub mtime: i64,
34 /// The number of changes to the data of the znode.
35 pub version: i32,
36 /// The number of changes to the children of the znode.
37 pub cversion: i32,
38 /// The number of changes to the ACL of the znode.
39 pub aversion: i32,
40 /// The session ID of the owner of this znode, if it is an ephemeral entry.
41 pub ephemeral_owner: i64,
42 /// The length of the data field of the znode.
43 pub data_length: i32,
44 /// The number of children this znode has.
45 pub num_children: i32,
46 /// The transaction ID that last modified the children of the znode.
47 pub pzxid: i64,
48}
49
50/// CreateMode value determines how the znode is created on ZooKeeper.
51#[repr(i32)]
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53pub enum CreateMode {
54 /// The znode will not be automatically deleted upon client's disconnect.
55 Persistent = 0,
56 /// The znode will be deleted upon the client's disconnect.
57 Ephemeral = 1,
58 /// The name of the znode will be appended with a monotonically increasing number. The actual
59 /// path name of a sequential node will be the given path plus a suffix `"i"` where *i* is the
60 /// current sequential number of the node. The sequence number is always fixed length of 10
61 /// digits, 0 padded. Once such a node is created, the sequential number will be incremented by
62 /// one.
63 PersistentSequential = 2,
64 /// The znode will be deleted upon the client's disconnect, and its name will be appended with a
65 /// monotonically increasing number.
66 EphemeralSequential = 3,
67 /// Container nodes are special purpose nodes useful for recipes such as leader, lock, etc. When
68 /// the last child of a container is deleted, the container becomes a candidate to be deleted by
69 /// the server at some point in the future. Given this property, you should be prepared to get
70 /// `ZkError::NoNode` when creating children inside of this container node.
71 Container = 4,
72 //
73 // 421
74 // 000
75 // ^----- is it a container?
76 // ^---- is it sequential?
77 // ^--- is it ephemeral?
78}