You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,18 +90,18 @@ Calls like `WatchTree` may return different events (or number of events) dependi
90
90
91
91
Only `Consul` and `etcd` have support for TLS and you should build and provide your own `config.TLS` object to feed the client. Support is planned for `zookeeper`.
92
92
93
-
##Roadmap
93
+
##Roadmap
94
94
95
95
- Make the API nicer to use (using `options`)
96
96
- Provide more options (`consistency` for example)
Copy file name to clipboardExpand all lines: docs/compatibility.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
#Cross-Backend Compatibility
1
+
#Cross-Backend Compatibility
2
2
3
3
The value of `libkv` is not to duplicate the code for programs that should support multiple distributed K/V stores like the classic `Consul`/`etcd`/`zookeeper` trio.
4
4
5
5
This document provides with general guidelines for users willing to support those backends with the same code using `libkv`.
6
6
7
7
Please note that most of those workarounds are going to disappear in the future with `etcd` APIv3.
8
8
9
-
##Etcd directory/key distinction
9
+
##Etcd directory/key distinction
10
10
11
11
`etcd` with APIv2 makes the distinction between keys and directories. The result with `libkv` is that when using the etcd driver:
12
12
@@ -17,7 +17,7 @@ This is fundamentaly different than `Consul` and `zookeeper` which are more perm
17
17
18
18
Apiv3 is in the work for `etcd`, which removes this key/directory distinction, but until then you should follow these workarounds to make your `libkv` code work across backends.
19
19
20
-
###Put
20
+
###Put
21
21
22
22
`etcd` cannot put values on directories, so this puts a major restriction compared to `Consul` and `zookeeper`.
Will work on `Consul` and `zookeeper` but fail for `etcd`. This is because the first `Put` in the case of `etcd` will recursively create the directory hierarchy and `path/to/key` is now considered as a directory. Thus, values should always be stored on leaves if the support for the three backends is planned.
34
34
35
-
###WatchTree
35
+
###WatchTree
36
36
37
37
When initializing the `WatchTree`, the natural way to do so is through the following code:
The code above will work for the three backends but make sure to not try to store any value at that path as the call to `Put` will fail for `etcd` (you can only put at `path/to/key/foo`, `path/to/key/bar` for example).
65
65
66
-
##Etcd distributed locking
66
+
##Etcd distributed locking
67
67
68
68
There is `Lock` mechanisms baked in the `coreos/etcd/client` for now. Instead, `libkv` has its own implementation of a `Lock` on top of `etcd`.
Copy file name to clipboardExpand all lines: docs/examples.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
#Examples
1
+
#Examples
2
2
3
3
This document contains useful example of usage for `libkv`. It might not be complete but provides with general informations on how to use the client.
4
4
5
-
##Create a store and use Put/Get/Delete
5
+
##Create a store and use Put/Get/Delete
6
6
7
7
```go
8
8
package main
@@ -62,7 +62,7 @@ func main() {
62
62
}
63
63
```
64
64
65
-
##List keys
65
+
##List keys
66
66
67
67
```go
68
68
// List will list all the keys under `key` if it contains a set of child keys/values
@@ -73,7 +73,7 @@ for _, pair := range entries {
73
73
74
74
```
75
75
76
-
##Watching for events on a single key (Watch)
76
+
##Watching for events on a single key (Watch)
77
77
78
78
You can use watches to watch modifications on a key. First you need to check if the key exists. If this is not the case, we need to create it using the `Put` function.
79
79
@@ -97,7 +97,7 @@ select {
97
97
98
98
```
99
99
100
-
##Watching for events happening on child keys (WatchTree)
100
+
##Watching for events happening on child keys (WatchTree)
101
101
102
102
You can use watches to watch modifications on a key. First you need to check if the key exists. If this is not the case, we need to create it using the `Put` function. There is a special step here though if you want your code to work across backends. Because `etcd` is a special case and it makes the distinction between directories and keys, we need to make sure that the created key is considered as a directory by enforcing `IsDir` at `true`.
0 commit comments