Oipo edited a comment on pull request #285:
URL: https://github.com/apache/celix/pull/285#issuecomment-698164298


   So X-Etcd-Index is tied to an etcd server (so in a cluster, you can have 
multiple I think, not sure).
   But the index used in the api is the modifiedIndex stored with a key.
   
   If we take a look at the [etcd API](https://etcd.io/docs/v2/api/) 
description:
   
   > node.createdIndex: an index is a unique, monotonically-incrementing 
integer created for each change to etcd. This specific index reflects the point 
in the etcd state member at which a given key was created. You may notice that 
in this example the index is 2 even though it is the first request you sent to 
the server. This is because there are internal commands that also change the 
state behind the scenes, like adding and syncing servers.
   > node.modifiedIndex: like node.createdIndex, this attribute is also an etcd 
index. Actions that cause the value to change include set, delete, update, 
create, compareAndSwap and compareAndDelete. Since the get and watch commands 
do not change state in the store, they do not change the value of 
node.modifiedIndex.
   
   It's probably best to do an `etcdlib_get()` before an `etcdlib_watch()`. If 
the return value is ETCDLIB_RC_ERROR, you can assume it is 0.
   
   Verifying this locally:
   ```
   oipo@oipo-X570-AORUS-ELITE:~$ curl http://127.0.0.1:2379/v2/keys/message3
   {"errorCode":100,"message":"Key not found","cause":"/message3","index":5266}
   oipo@oipo-X570-AORUS-ELITE:~$ curl http://127.0.0.1:2379/v2/keys
   
{"action":"get","node":{"dir":true,"nodes":[{"key":"/hier","dir":true,"modifiedIndex":13,"createdIndex":13}]}}
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to