Comments (5)
Thanks for opening the issue @spikecurtis
I'm actually torn between just changing the documentation and waiting for the support in etcd v3
(which will come at some point in the future, without certitude), or using hidden keys to store directory informations.
If I'm not mistaken, using hidden keys is the only way to store informations for a directory without the key being listed or events being triggered for that key. The interoperability with other client libraries is not really an issue in that case: they must point directly to /path/to/__data__
and know about the key structure anyway.
I'm not against making the change in that case because this is a bug. Even though this is a design issue in etcd
that must be eventually fixed.
from libkv.
@abronan it's more than other client libraries seeing keys they wouldn't recognize.
Suppose you have an existing application that writes to etcd
, and you want to use libkv
to interoperate with that application. If we append __data__
to every key the user of libkv
supplies, then they will be unable to read or write to the "normal" keys the existing application uses.
We can't just use this trick only for "directory" keys, since we won't know a priori whether the path is a leaf or not. So every Put
and Get
for the etcd
backend would have the suffix.
My personal feeling is to change the documentation. At this stage, anyone serious about multiple backends better be testing them with their application. Other options involve a lot of black magic and complexity for very little benefit.
from libkv.
To my understanding, the prefix would only be used for a single unique key __data__
under each directory (and not every key).
So we would have a structure like this:
path/to/
path/to/__data__ // Holds the data for the directory, hidden to regular GET operations like List/Watch, etc.
path/to/key1
path/to/key2
path/to/key3
path/
path/__data__ // We can have a key here as well because "path/" is a directory
The process of Put
for etcd
and to actually hide the directory/key distinction would be something like:
Put("path/to/directory/", []byte(""), nil)
// "path/to/directory/" is a regular key
Put("path/to/directory/node1/", []byte(""), nil)
// Changes "path/to/directory/" from a key to a directory, moving the data to the child key `__data__`
Put("path/", []byte(""), nil)
// We create a new child key `__data__` under "path/" to hold the data
Now, if you try to Get("path/to/directory/")
, because this is a directory, it will append __data__
to get back the value from the hidden key.
Unless I'm missing something obvious, this would be possible but this involves a lot of trickery and back and forth transformations between key
and directory
.
Other options involve a lot of black magic and complexity for very little benefit.
I actually agree with this. Not sure if this is a good option as this hides a lot of things that could backfire on us if people are upgrading to new versions of etcd
or using other client libraries. It is definitely possible but this will change a lot of code under each call to make the distinction and handle special cases.
Is there any actual Issue or open PR in the etcd
repository to track the changes in API v3
? We could probably concentrate our efforts here and help making this change happen in etcd
.
from libkv.
@spikecurtis After a discussion with @kelseyhightower (thanks for all the infos!), etcd API v3
will definitely drop this distinction about directories and keys. So we might just wait and document it properly until this drops and we make the appropriate changes :)
from libkv.
Base on my observation, etcd
and zookeeper
act like a tree tree
, consul
on the other hand like a hash table.
Say we Put("foot/to/new/node")
to an empty backend, if the command succeed, etcd
and zookeeper
will have the same amount of keys(3 in this case), while consul
only create 1 key.
and consul
treat foo
, foo/
as two different keys.
theses should be considered.
from libkv.
Related Issues (20)
- do libkv support etcd v3? HOT 1
- bug in WatchTree for etcd
- Add function to list all the key-values in the boltdb store HOT 1
- add option to disable quorum for gets with etcd backend HOT 1
- Lock() of Locker interface should probably take a receive-only channel
- In etcd at least, waitLock() ignores an action HOT 1
- A race is possible in etcd's Lock() HOT 1
- Implement a Kubernetes driver
- Panic in older versions of consul
- Active again? HOT 2
- Optionally disable ZooKeeper logging
- Inconsistent reference to license for docs
- When multiple etcd stores are passed to the API. Which one is given preference? HOT 1
- can not get zookeeper path data, node cannot be discovery.
- panic in List() method with boltdb backend
- zookeeper GetW function seems has a atomic error
- possible data race in AddStore()
- implemented a etcd v3 api store HOT 1
- Travis-ci: AMD64 build is failing HOT 1
- Valkeyrie: a maintained fork created by the original author of libkv HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libkv.