@@ -936,6 +936,7 @@ func (c *Conn) request(opcode int32, req interface{}, res interface{}, recvFunc
936
936
}
937
937
}
938
938
939
+ // AddAuth adds an authentication config to the connection.
939
940
func (c * Conn ) AddAuth (scheme string , auth []byte ) error {
940
941
_ , err := c .request (opSetAuth , & setAuthRequest {Type : 0 , Scheme : scheme , Auth : auth }, & setAuthResponse {}, nil )
941
942
@@ -962,6 +963,7 @@ func (c *Conn) AddAuth(scheme string, auth []byte) error {
962
963
return nil
963
964
}
964
965
966
+ // Children returns the children of a znode.
965
967
func (c * Conn ) Children (path string ) ([]string , * Stat , error ) {
966
968
if err := validatePath (path , false ); err != nil {
967
969
return nil , nil , err
@@ -975,6 +977,7 @@ func (c *Conn) Children(path string) ([]string, *Stat, error) {
975
977
return res .Children , & res .Stat , err
976
978
}
977
979
980
+ // ChildrenW returns the children of a znode and sets a watch.
978
981
func (c * Conn ) ChildrenW (path string ) ([]string , * Stat , <- chan Event , error ) {
979
982
if err := validatePath (path , false ); err != nil {
980
983
return nil , nil , nil , err
@@ -993,6 +996,7 @@ func (c *Conn) ChildrenW(path string) ([]string, *Stat, <-chan Event, error) {
993
996
return res .Children , & res .Stat , ech , err
994
997
}
995
998
999
+ // Get gets the contents of a znode.
996
1000
func (c * Conn ) Get (path string ) ([]byte , * Stat , error ) {
997
1001
if err := validatePath (path , false ); err != nil {
998
1002
return nil , nil , err
@@ -1025,6 +1029,7 @@ func (c *Conn) GetW(path string) ([]byte, *Stat, <-chan Event, error) {
1025
1029
return res .Data , & res .Stat , ech , err
1026
1030
}
1027
1031
1032
+ // Set updates the contents of a znode.
1028
1033
func (c * Conn ) Set (path string , data []byte , version int32 ) (* Stat , error ) {
1029
1034
if err := validatePath (path , false ); err != nil {
1030
1035
return nil , err
@@ -1038,6 +1043,10 @@ func (c *Conn) Set(path string, data []byte, version int32) (*Stat, error) {
1038
1043
return & res .Stat , err
1039
1044
}
1040
1045
1046
+ // Create creates a znode.
1047
+ // The returned path is the new path assigned by the server, it may not be the
1048
+ // same as the input, for example when creating a sequence znode the returned path
1049
+ // will be the input path with a sequence number appended.
1041
1050
func (c * Conn ) Create (path string , data []byte , flags int32 , acl []ACL ) (string , error ) {
1042
1051
if err := validatePath (path , flags & FlagSequence == FlagSequence ); err != nil {
1043
1052
return "" , err
@@ -1051,6 +1060,7 @@ func (c *Conn) Create(path string, data []byte, flags int32, acl []ACL) (string,
1051
1060
return res .Path , err
1052
1061
}
1053
1062
1063
+ // CreateContainer creates a container znode and returns the path.
1054
1064
func (c * Conn ) CreateContainer (path string , data []byte , flags int32 , acl []ACL ) (string , error ) {
1055
1065
if err := validatePath (path , flags & FlagSequence == FlagSequence ); err != nil {
1056
1066
return "" , err
@@ -1064,6 +1074,7 @@ func (c *Conn) CreateContainer(path string, data []byte, flags int32, acl []ACL)
1064
1074
return res .Path , err
1065
1075
}
1066
1076
1077
+ // CreateTTL creates a TTL znode, which will be automatically deleted by server after the TTL.
1067
1078
func (c * Conn ) CreateTTL (path string , data []byte , flags int32 , acl []ACL , ttl time.Duration ) (string , error ) {
1068
1079
if err := validatePath (path , flags & FlagSequence == FlagSequence ); err != nil {
1069
1080
return "" , err
@@ -1126,6 +1137,7 @@ func (c *Conn) CreateProtectedEphemeralSequential(path string, data []byte, acl
1126
1137
return "" , err
1127
1138
}
1128
1139
1140
+ // Delete deletes a znode.
1129
1141
func (c * Conn ) Delete (path string , version int32 ) error {
1130
1142
if err := validatePath (path , false ); err != nil {
1131
1143
return err
@@ -1135,6 +1147,7 @@ func (c *Conn) Delete(path string, version int32) error {
1135
1147
return err
1136
1148
}
1137
1149
1150
+ // Exists tells the existence of a znode.
1138
1151
func (c * Conn ) Exists (path string ) (bool , * Stat , error ) {
1139
1152
if err := validatePath (path , false ); err != nil {
1140
1153
return false , nil , err
@@ -1153,6 +1166,7 @@ func (c *Conn) Exists(path string) (bool, *Stat, error) {
1153
1166
return exists , & res .Stat , err
1154
1167
}
1155
1168
1169
+ // ExistsW tells the existence of a znode and sets a watch.
1156
1170
func (c * Conn ) ExistsW (path string ) (bool , * Stat , <- chan Event , error ) {
1157
1171
if err := validatePath (path , false ); err != nil {
1158
1172
return false , nil , nil , err
@@ -1178,6 +1192,7 @@ func (c *Conn) ExistsW(path string) (bool, *Stat, <-chan Event, error) {
1178
1192
return exists , & res .Stat , ech , err
1179
1193
}
1180
1194
1195
+ // GetACL gets the ACLs of a znode.
1181
1196
func (c * Conn ) GetACL (path string ) ([]ACL , * Stat , error ) {
1182
1197
if err := validatePath (path , false ); err != nil {
1183
1198
return nil , nil , err
@@ -1190,6 +1205,8 @@ func (c *Conn) GetACL(path string) ([]ACL, *Stat, error) {
1190
1205
}
1191
1206
return res .Acl , & res .Stat , err
1192
1207
}
1208
+
1209
+ // SetACL updates the ACLs of a znode.
1193
1210
func (c * Conn ) SetACL (path string , acl []ACL , version int32 ) (* Stat , error ) {
1194
1211
if err := validatePath (path , false ); err != nil {
1195
1212
return nil , err
@@ -1203,6 +1220,9 @@ func (c *Conn) SetACL(path string, acl []ACL, version int32) (*Stat, error) {
1203
1220
return & res .Stat , err
1204
1221
}
1205
1222
1223
+ // Sync flushes the channel between process and the leader of a given znode,
1224
+ // you may need it if you want identical views of ZooKeeper data for 2 client instances.
1225
+ // Please refer to the "Consistency Guarantees" section of ZK document for more details.
1206
1226
func (c * Conn ) Sync (path string ) (string , error ) {
1207
1227
if err := validatePath (path , false ); err != nil {
1208
1228
return "" , err
@@ -1216,6 +1236,7 @@ func (c *Conn) Sync(path string) (string, error) {
1216
1236
return res .Path , err
1217
1237
}
1218
1238
1239
+ // MultiResponse is the result of a Multi call.
1219
1240
type MultiResponse struct {
1220
1241
Stat * Stat
1221
1242
String string
0 commit comments