forked from samuel/go-zookeeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.go
132 lines (120 loc) · 2.87 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package zk
const (
protocolVersion = 0
)
const (
opNotify = 0
opCreate = 1
opDelete = 2
opExists = 3
opGetData = 4
opSetData = 5
opGetAcl = 6
opSetAcl = 7
opGetChildren = 8
opSync = 9
opPing = 11
opGetChildren2 = 12
opCheck = 13
opMulti = 14
opClose = -11
opSetAuth = 100
opSetWatches = 101
// Not in protocol, used internally
opWatcherEvent = -2
)
const (
eventTypeNone = -1
eventTypeNodeCreated = 1
eventTypeNodeDeleted = 2
eventTypeNodeDataChanged = 3
eventTypeNodeChildrenChanged = 4
)
const (
stateUnknown = -1
stateDisconnected = 0
stateNoSyncConnected = 1 // deprecated, unused, never generated
stateSyncConnected = 3
stateAuthFailed = 4
stateConnectedReadOnly = 5
stateSaslAuthenticated = 6
stateExpired = -112
// stateAuthFailed = -113??
stateConnected = 100
stateHasSession = 101
)
const (
errOk = 0
// System and server-side errors
errSystemError = -1
errRuntimeInconsistency = -2
errDataInconsistency = -3
errConncetionLoss = -4
errMarshallingError = -5
errUnimplemented = -6
errOperationTimeout = -7
errBadArguments = -8
errInvalidState = -9
// API errors
errApiError = -100
errNoNode = -101 // *
errNoAuth = -102
errBadVersion = -103 // *
errNoChildrenForEphemerals = -108
errNodeExists = -110 // *
errNotEmpty = -111
errSessionExpired = -112
errInvalidCallback = -113
errInvalidAcl = -114
errAuthFailed = -115
errClosing = -116
errNothing = -117
errSessionMoved = -118
)
const (
PermRead = 1 << iota
PermWrite
PermCreate
PermDelete
PermAdmin
PermAll = 0x1f
)
var (
emptyPassword = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
opNames = map[int32]string{
opNotify: "notify",
opCreate: "create",
opDelete: "delete",
opExists: "exists",
opGetData: "getData",
opSetData: "setData",
opGetAcl: "getACL",
opSetAcl: "setACL",
opGetChildren: "getChildren",
opSync: "sync",
opPing: "ping",
opGetChildren2: "getChildren2",
opCheck: "check",
opMulti: "multi",
opClose: "close",
opSetAuth: "setAuth",
opSetWatches: "setWatches",
opWatcherEvent: "watcherEvent",
}
)
type EventType int
func (t EventType) String() string {
switch t {
case eventTypeNone:
return "None"
case eventTypeNodeCreated:
return "NodeCreated"
case eventTypeNodeDeleted:
return "NodeDeleted"
case eventTypeNodeDataChanged:
return "NodeDataChanged"
case eventTypeNodeChildrenChanged:
return "ChildrenChanged"
}
return "Unknown"
}