Skip to content

1 - Discovery service protocol

Discover other etcd members in a cluster bootstrap phase

Discovery service protocol helps new etcd member to discover all other members in cluster bootstrap phase using a shared discovery URL.

Discovery service protocol is only used in cluster bootstrap phase, and cannot be used for runtime reconfiguration or cluster monitoring.

The protocol uses a new discovery token to bootstrap one unique etcd cluster. Remember that one discovery token can represent only one etcd cluster. As long as discovery protocol on this token starts, even if it fails halfway, it must not be used to bootstrap another etcd cluster.

The rest of this article will walk through the discovery process with examples that correspond to a self-hosted discovery cluster. The public discovery service, discovery.etcd.io, functions the same way, but with a layer of polish to abstract away ugly URLs, generate UUIDs automatically, and provide some protections against excessive requests. At its core, the public discovery service still uses an etcd cluster as the data store as described in this document.

Protocol workflow

The idea of discovery protocol is to use an internal etcd cluster to coordinate bootstrap of a new cluster. First, all new members interact with discovery service and help to generate the expected member list. Then each new member bootstraps its server using this list, which performs the same functionality as -initial-cluster flag.

In the following example workflow, we will list each step of protocol in curl format for ease of understanding.

By convention the etcd discovery protocol uses the key prefix _etcd/registry. If http://example.com hosts an etcd cluster for discovery service, a full URL to discovery keyspace will be http://example.com/v2/keys/_etcd/registry. We will use this as the URL prefix in the example.

Creating a new discovery token

Generate a unique token that will identify the new cluster. This will be used as a unique prefix in discovery keyspace in the following steps. An easy way to do this is to use uuidgen:

UUID=$(uuidgen)

Specifying the expected cluster size

The discovery token expects a cluster size that must be specified. The size is used by the discovery service to know when it has found all members that will initially form the cluster.

curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size -d value=${cluster_size}

Usually the cluster size is 3, 5 or 7. Check optimal cluster size for more details.

Bringing up etcd processes

Given the discovery URL, use it as -discovery flag and bring up etcd processes. Every etcd process will follow this next few steps internally if given a -discovery flag.

Registering itself

The first thing for etcd process is to register itself into the discovery URL as a member. This is done by creating member ID as a key in the discovery URL.

curl -X PUT http://example.com/v2/keys/_etcd/registry/${UUID}/${member_id}?prevExist=false -d value="${member_name}=${member_peer_url_1}&${member_name}=${member_peer_url_2}"

Checking the status

It checks the expected cluster size and registration status in discovery URL, and decides what the next action is.

curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}/_config/size
curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}

If registered members are still not enough, it will wait for left members to appear.

If the number of registered members is bigger than the expected size N, it treats the first N registered members as the member list for the cluster. If the member itself is in the member list, the discovery procedure succeeds and it fetches all peers through the member list. If it is not in the member list, the discovery procedure finishes with the failure that the cluster has been full.

In etcd implementation, the member may check the cluster status even before registering itself. So it could fail quickly if the cluster has been full.

Waiting for all members

The wait process is described in detail in the etcd API documentation .

curl -X GET http://example.com/v2/keys/_etcd/registry/${UUID}?wait=true&waitIndex=${current_etcd_index}

It keeps waiting until finding all members.

Public discovery service

CoreOS Inc. hosts a public discovery service at https://discovery.etcd.io/ , which provides some nice features for ease of use.

Mask key prefix

Public discovery service will redirect https://discovery.etcd.io/${UUID} to etcd cluster behind for the key at /v2/keys/_etcd/registry. It masks register key prefix for short and readable discovery url.

Get new token

GET /new

Sent query:
	size=${cluster_size}
Possible status codes:
	200 OK
	400 Bad Request
200 Body:
	generated discovery url

The generation process in the service follows the steps from Creating a New Discovery Token to Specifying the Expected Cluster Size .

Check discovery status

GET /${UUID}

The status for this discovery token, including the machines that have been registered, can be checked by requesting the value of the UUID.

Open-source repository

The repository is located at https://github.com/coreos/discovery.etcd.io . It could be used to build a custom discovery service.

2 - Set up a local cluster

Configuring local clusters for testing and development

For testing and development deployments, the quickest and easiest way is to configure a local cluster. For a production deployment, refer to the clustering section.

Local standalone cluster

Starting a cluster

Run the following to deploy an etcd cluster as a standalone cluster:

$ ./etcd
...

If the etcd binary is not present in the current working directory, it might be located either at $GOPATH/bin/etcd or at /usr/local/bin/etcd. Run the command appropriately.

The running etcd member listens on localhost:2379 for client requests.

Interacting with the cluster

Use etcdctl to interact with the running cluster:

  1. Store an example key-value pair in the cluster:

      $ ./etcdctl put foo bar
      OK

    If OK is printed, storing key-value pair is successful.

  2. Retrieve the value of foo:

    $ ./etcdctl get foo
    bar

    If bar is returned, interaction with the etcd cluster is working as expected.

Local multi-member cluster

Starting a cluster

A Procfile at the base of the etcd git repository is provided to easily configure a local multi-member cluster. To start a multi-member cluster, navigate to the root of the etcd source tree and perform the following:

  1. Install goreman to control Procfile-based applications:

    $ go install github.com/mattn/goreman@latest
  2. Start a cluster with goreman using etcd’s stock Procfile:

    $ goreman -f Procfile start

    The members start running. They listen on localhost:2379, localhost:22379, and localhost:32379 respectively for client requests.

Interacting with the cluster

Use etcdctl to interact with the running cluster:

  1. Print the list of members:

    $ etcdctl --write-out=table --endpoints=localhost:2379 member list

    The list of etcd members are displayed as follows:

    +------------------+---------+--------+------------------------+------------------------+
    |        ID        | STATUS  |  NAME  |       PEER ADDRS       |      CLIENT ADDRS      |
    +------------------+---------+--------+------------------------+------------------------+
    | 8211f1d0f64f3269 | started | infra1 | http://127.0.0.1:2380  | http://127.0.0.1:2379  |
    | 91bc3c398fb3c146 | started | infra2 | http://127.0.0.1:22380 | http://127.0.0.1:22379 |
    | fd422379fda50e48 | started | infra3 | http://127.0.0.1:32380 | http://127.0.0.1:32379 |
    +------------------+---------+--------+------------------------+------------------------+
  2. Store an example key-value pair in the cluster:

    $ etcdctl put foo bar
    OK

    If OK is printed, storing key-value pair is successful.

Testing fault tolerance

To exercise etcd’s fault tolerance, kill a member and attempt to retrieve the key.

  1. Identify the process name of the member to be stopped.

    The Procfile lists the properties of the multi-member cluster. For example, consider the member with the process name, etcd2.

  2. Stop the member:

    # kill etcd2
    $ goreman run stop etcd2
  3. Store a key:

    $ etcdctl put key hello
    OK
  4. Retrieve the key that is stored in the previous step:

    $ etcdctl get key
    hello
  5. Retrieve a key from the stopped member:

    $ etcdctl --endpoints=localhost:22379 get key

    The command should display an error caused by connection failure:

    2017/06/18 23:07:35 grpc: Conn.resetTransport failed to create client transport: connection error: desc = "transport: dial tcp 127.0.0.1:22379: getsockopt: connection refused"; Reconnecting to "localhost:22379"
    Error:  grpc: timed out trying to connect
  6. Restart the stopped member:

    $ goreman run restart etcd2
  7. Get the key from the restarted member:

    $ etcdctl --endpoints=localhost:22379 get key
    hello

    Restarting the member re-establish the connection. etcdctl will now be able to retrieve the key successfully. To learn more about interacting with etcd, read interacting with etcd section .

3 - Interacting with etcd

etcdctl: a command line tool for interacting with the etcd server

Users mostly interact with etcd by putting or getting the value of a key. This section describes how to do that by using etcdctl, a command line tool for interacting with etcd server. The concepts described here should apply to the gRPC APIs or client library APIs.

The API version used by etcdctl to speak to etcd may be set to version 2 or 3 via the ETCDCTL_API environment variable. By default, etcdctl on master (3.4) uses the v3 API and earlier versions (3.3 and earlier) default to the v2 API.

Note that any key that was created using the v2 API will not be able to be queried via the v3 API. A v3 API etcdctl get of a v2 key will exit with 0 and no key data, this is the expected behaviour.

export ETCDCTL_API=3

Find versions

etcdctl version and Server API version can be useful in finding the appropriate commands to be used for performing various operations on etcd.

Here is the command to find the versions:

$ etcdctl version
etcdctl version: 3.1.0-alpha.0+git
API version: 3.1

Write a key

Applications store keys into the etcd cluster by writing to keys. Every stored key is replicated to all etcd cluster members through the Raft protocol to achieve consistency and reliability.

Here is the command to set the value of key foo to bar:

$ etcdctl put foo bar
OK

Also a key can be set for a specified interval of time by attaching lease to it.

Here is the command to set the value of key foo1 to bar1 for 10s.

$ etcdctl put foo1 bar1 --lease=1234abcd
OK
Note

The lease id 1234abcd in the above command refers to id returned on creating the lease of 10s. This id can then be attached to the key.

Read keys

Applications can read values of keys from an etcd cluster. Queries may read a single key, or a range of keys.

Suppose the etcd cluster has stored the following keys:

foo = bar
foo1 = bar1
foo2 = bar2
foo3 = bar3

Here is the command to read the value of key foo:

$ etcdctl get foo
foo
bar

Here is the command to read the value of key foo in hex format:

$ etcdctl get foo --hex
\x66\x6f\x6f          # Key
\x62\x61\x72          # Value

Here is the command to read only the value of key foo:

$ etcdctl get foo --print-value-only
bar

Here is the command to range over the keys from foo to foo3:

$ etcdctl get foo foo3
foo
bar
foo1
bar1
foo2
bar2
Note

foo3 is excluded since the range is over the half-open interval [foo, foo3), excluding foo3.

Here is the command to range over all keys prefixed with foo:

$ etcdctl get --prefix foo
foo
bar
foo1
bar1
foo2
bar2
foo3
bar3

Here is the command to range over all keys prefixed with foo, limiting the number of results to 2:

$ etcdctl get --prefix --limit=2 foo
foo
bar
foo1
bar1

Here is the command to range over all keys prefixed with foo using the RangeStream RPC. The result is identical to a unary Range:

$ etcdctl get --stream --prefix foo
foo
bar
foo1
bar1
foo2
bar2
foo3
bar3

--stream does not support --order, --sort-by, or revision filters.

Read past version of keys

Applications may want to read superseded versions of a key. For example, an application may wish to roll back to an old configuration by accessing an earlier version of a key. Alternatively, an application may want a consistent view over multiple keys through multiple requests by accessing key history. Since every modification to the etcd cluster key-value store increments the global revision of an etcd cluster, an application can read superseded keys by providing an older etcd revision.

Suppose an etcd cluster already has the following keys:

foo = bar         # revision = 2
foo1 = bar1       # revision = 3
foo = bar_new     # revision = 4
foo1 = bar1_new   # revision = 5

Here are an example to access the past versions of keys:

$ etcdctl get --prefix foo # access the most recent versions of keys
foo
bar_new
foo1
bar1_new

$ etcdctl get --prefix --rev=4 foo # access the versions of keys at revision 4
foo
bar_new
foo1
bar1

$ etcdctl get --prefix --rev=3 foo # access the versions of keys at revision 3
foo
bar
foo1
bar1

$ etcdctl get --prefix --rev=2 foo # access the versions of keys at revision 2
foo
bar

$ etcdctl get --prefix --rev=1 foo # access the versions of keys at revision 1

Read keys which are greater than or equal to the byte value of the specified key

Applications may want to read keys which are greater than or equal to the byte value of the specified key.

Suppose an etcd cluster already has the following keys:

a = 123
b = 456
z = 789

Here is the command to read keys which are greater than or equal to the byte value of key b :

$ etcdctl get --from-key b
b
456
z
789

Delete keys

Applications can delete a key or a range of keys from an etcd cluster.

Suppose an etcd cluster already has the following keys:

foo = bar
foo1 = bar1
foo3 = bar3
zoo = val
zoo1 = val1
zoo2 = val2
a = 123
b = 456
z = 789

Here is the command to delete key foo:

$ etcdctl del foo
1 # one key is deleted

Here is the command to delete keys ranging from foo to foo9:

$ etcdctl del foo foo9
2 # two keys are deleted

Here is the command to delete key zoo with the deleted key value pair returned:

$ etcdctl del --prev-kv zoo
1   # one key is deleted
zoo # deleted key
val # the value of the deleted key

Here is the command to delete keys having prefix as zoo:

$ etcdctl del --prefix zoo
2 # two keys are deleted

Here is the command to delete keys which are greater than or equal to the byte value of key b :

$ etcdctl del --from-key b
2 # two keys are deleted

Watch key changes

Applications can watch on a key or a range of keys to monitor for any updates.

Here is the command to watch on key foo:

$ etcdctl watch foo
# in another terminal: etcdctl put foo bar
PUT
foo
bar

Here is the command to watch on key foo in hex format:

$ etcdctl watch foo --hex
# in another terminal: etcdctl put foo bar
PUT
\x66\x6f\x6f          # Key
\x62\x61\x72          # Value

Here is the command to watch on a range key from foo to foo9:

$ etcdctl watch foo foo9
# in another terminal: etcdctl put foo bar
PUT
foo
bar
# in another terminal: etcdctl put foo1 bar1
PUT
foo1
bar1

Here is the command to watch on keys having prefix foo:

$ etcdctl watch --prefix foo
# in another terminal: etcdctl put foo bar
PUT
foo
bar
# in another terminal: etcdctl put fooz1 barz1
PUT
fooz1
barz1

Here is the command to watch on multiple keys foo and zoo:

$ etcdctl watch -i
$ watch foo
$ watch zoo
# in another terminal: etcdctl put foo bar
PUT
foo
bar
# in another terminal: etcdctl put zoo val
PUT
zoo
val

Watch historical changes of keys

Applications may want to watch for historical changes of keys in etcd. For example, an application may wish to receive all the modifications of a key; if the application stays connected to etcd, then watch is good enough. However, if the application or etcd fails, a change may happen during the failure, and the application will not receive the update in real time. To guarantee the update is delivered, the application must be able to watch for historical changes to keys. To do this, an application can specify a historical revision on a watch, just like reading past version of keys.

Suppose we finished the following sequence of operations:

$ etcdctl put foo bar         # revision = 2
OK
$ etcdctl put foo1 bar1       # revision = 3
OK
$ etcdctl put foo bar_new     # revision = 4
OK
$ etcdctl put foo1 bar1_new   # revision = 5
OK

Here is an example to watch the historical changes:

# watch for changes on key `foo` since revision 2
$ etcdctl watch --rev=2 foo
PUT
foo
bar
PUT
foo
bar_new
# watch for changes on key `foo` since revision 3
$ etcdctl watch --rev=3 foo
PUT
foo
bar_new

Here is an example to watch only from the last historical change:

# watch for changes on key `foo` and return last revision value along with modified value
$ etcdctl watch --prev-kv foo
# in another terminal: etcdctl put foo bar_latest
PUT
foo         # key
bar_new     # last value of foo key before modification
foo         # key
bar_latest  # value of foo key after modification

Watch progress

Applications may want to check the progress of a watch to determine how up-to-date the watch stream is. For example, if a watch is used to update a cache, it can be useful to know if the cache is stale compared to the revision from a quorum read.

Progress requests can be issued using the “progress” command in interactive watch session to ask the etcd server to send a progress notify update in the watch stream:

$ etcdctl watch -i
$ watch a
$ progress
progress notify: 1
# in another terminal: etcdctl put x 0
# in another terminal: etcdctl put y 1
$ progress
progress notify: 3
Note

The revision number in the progress notify response is the revision from the local etcd server node that the watch stream is connected to. If this node is partitioned and not part of quorum, this progress notify revision might be lower than the revision returned by a quorum read against a non-partitioned etcd server node.

Compacted revisions

As we mentioned, etcd keeps revisions so that applications can read past versions of keys. However, to avoid accumulating an unbounded amount of history, it is important to compact past revisions. After compacting, etcd removes historical revisions, releasing resources for future use. All superseded data with revisions before the compacted revision will be unavailable.

Here is the command to compact the revisions:

$ etcdctl compact 5
compacted revision 5

# any revisions before the compacted one are not accessible
$ etcdctl get --rev=4 foo
Error:  rpc error: code = 11 desc = etcdserver: mvcc: required revision has been compacted
Note

The current revision of etcd server can be found using get command on any key (existent or non-existent) in json format. Example is shown below for mykey which does not exist in etcd server:

$ etcdctl get mykey -w=json
{"header":{"cluster_id":14841639068965178418,"member_id":10276657743932975437,"revision":15,"raft_term":4}}

Grant leases

Applications can grant leases for keys from an etcd cluster. When a key is attached to a lease, its lifetime is bound to the lease’s lifetime which in turn is governed by a time-to-live (TTL). Each lease has a minimum time-to-live (TTL) value specified by the application at grant time. The lease’s actual TTL value is at least the minimum TTL and is chosen by the etcd cluster. Once a lease’s TTL elapses, the lease expires and all attached keys are deleted.

Here is the command to grant a lease:

# grant a lease with 60 second TTL
$ etcdctl lease grant 60
lease 32695410dcc0ca06 granted with TTL(60s)

# attach key foo to lease 32695410dcc0ca06
$ etcdctl put --lease=32695410dcc0ca06 foo bar
OK

Revoke leases

Applications revoke leases by lease ID. Revoking a lease deletes all of its attached keys.

Suppose we finished the following sequence of operations:

$ etcdctl lease grant 60
lease 32695410dcc0ca06 granted with TTL(60s)
$ etcdctl put --lease=32695410dcc0ca06 foo bar
OK

Here is the command to revoke the same lease:

$ etcdctl lease revoke 32695410dcc0ca06
lease 32695410dcc0ca06 revoked

$ etcdctl get foo
# empty response since foo is deleted due to lease revocation

Keep leases alive

Applications can keep a lease alive by refreshing its TTL so it does not expire.

Suppose we finished the following sequence of operations:

$ etcdctl lease grant 60
lease 32695410dcc0ca06 granted with TTL(60s)

Here is the command to keep the same lease alive:

$ etcdctl lease keep-alive 32695410dcc0ca06
lease 32695410dcc0ca06 keepalived with TTL(60)
lease 32695410dcc0ca06 keepalived with TTL(60)
lease 32695410dcc0ca06 keepalived with TTL(60)
...

Get lease information

Applications may want to know about lease information, so that they can be renewed or to check if the lease still exists or it has expired. Applications may also want to know the keys to which a particular lease is attached.

Suppose we finished the following sequence of operations:

# grant a lease with 500 second TTL
$ etcdctl lease grant 500
lease 694d5765fc71500b granted with TTL(500s)

# attach key zoo1 to lease 694d5765fc71500b
$ etcdctl put zoo1 val1 --lease=694d5765fc71500b
OK

# attach key zoo2 to lease 694d5765fc71500b
$ etcdctl put zoo2 val2 --lease=694d5765fc71500b
OK

Here is the command to get information about the lease:

$ etcdctl lease timetolive 694d5765fc71500b
lease 694d5765fc71500b granted with TTL(500s), remaining(258s)

Here is the command to get information about the lease along with the keys attached with the lease:

$ etcdctl lease timetolive --keys 694d5765fc71500b
lease 694d5765fc71500b granted with TTL(500s), remaining(132s), attached keys([zoo2 zoo1])

# if the lease has expired or does not exist it will give the below response:
Error:  etcdserver: requested lease not found

4 - Why gRPC gateway

Why you should consider using the gRPC gateway

etcd v3 uses gRPC for its messaging protocol. The etcd project includes a gRPC-based Go client and a command line utility, etcdctl , for communicating with an etcd cluster through gRPC. For languages with no gRPC support, etcd provides a JSON gRPC gateway . This gateway serves a RESTful proxy that translates HTTP/JSON requests into gRPC messages.

Using gRPC gateway

The gateway accepts a JSON mapping for etcd’s protocol buffer message definitions. Note that key and value fields are defined as byte arrays and therefore must be base64 encoded in JSON. The following examples use curl, but any HTTP/JSON client should work all the same.

Notes

gRPC gateway endpoint has changed since etcd v3.3:

  • etcd v3.2 or before uses only [CLIENT-URL]/v3alpha/*.
  • etcd v3.3 uses [CLIENT-URL]/v3beta/* while keeping [CLIENT-URL]/v3alpha/*.
  • etcd v3.4 uses [CLIENT-URL]/v3/* while keeping [CLIENT-URL]/v3beta/*.
    • [CLIENT-URL]/v3alpha/* is deprecated.
  • etcd v3.5 or later uses only [CLIENT-URL]/v3/*.
    • [CLIENT-URL]/v3beta/* is deprecated.

gRPC-gateway does not support authentication using TLS Common Name.

Put and get keys

Use the /v3/kv/range and /v3/kv/put services to read and write keys:

<<COMMENT
https://www.base64encode.org/
foo is 'Zm9v' in Base64
bar is 'YmFy'
COMMENT

curl -L http://localhost:2379/v3/kv/put \
  -X POST -d '{"key": "Zm9v", "value": "YmFy"}'
# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"}}

curl -L http://localhost:2379/v3/kv/range \
  -X POST -d '{"key": "Zm9v"}'
# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}],"count":"1"}

# get all keys prefixed with "foo"
curl -L http://localhost:2379/v3/kv/range \
  -X POST -d '{"key": "Zm9v", "range_end": "Zm9w"}'
# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"3"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}],"count":"1"}

Watch keys

Use the /v3/watch service to watch keys:

curl -N http://localhost:2379/v3/watch \
  -X POST -d '{"create_request": {"key":"Zm9v"} }' &
# {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"1","raft_term":"2"},"created":true}}

curl -L http://localhost:2379/v3/kv/put \
  -X POST -d '{"key": "Zm9v", "value": "YmFy"}' >/dev/null 2>&1
# {"result":{"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"2","raft_term":"2"},"events":[{"kv":{"key":"Zm9v","create_revision":"2","mod_revision":"2","version":"1","value":"YmFy"}}]}}

Transactions

Issue a transaction with /v3/kv/txn:

# target CREATE
curl -L http://localhost:2379/v3/kv/txn \
  -X POST \
  -d '{"compare":[{"target":"CREATE","key":"Zm9v","createRevision":"2"}],"success":[{"requestPut":{"key":"Zm9v","value":"YmFy"}}]}'
# {"header":{"cluster_id":"12585971608760269493","member_id":"13847567121247652255","revision":"3","raft_term":"2"},"succeeded":true,"responses":[{"response_put":{"header":{"revision":"3"}}}]}
# target VERSION
curl -L http://localhost:2379/v3/kv/txn \
  -X POST \
  -d '{"compare":[{"version":"4","result":"EQUAL","target":"VERSION","key":"Zm9v"}],"success":[{"requestRange":{"key":"Zm9v"}}]}'
# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"6","raft_term":"3"},"succeeded":true,"responses":[{"response_range":{"header":{"revision":"6"},"kvs":[{"key":"Zm9v","create_revision":"2","mod_revision":"6","version":"4","value":"YmF6"}],"count":"1"}}]}

Authentication

Set up authentication with the /v3/auth service:

# create root user
curl -L http://localhost:2379/v3/auth/user/add \
  -X POST -d '{"name": "root", "password": "pass"}'
# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}

# create root role
curl -L http://localhost:2379/v3/auth/role/add \
  -X POST -d '{"name": "root"}'
# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}

# grant root role
curl -L http://localhost:2379/v3/auth/user/grant \
  -X POST -d '{"user": "root", "role": "root"}'
# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}

# enable auth
curl -L http://localhost:2379/v3/auth/enable -X POST -d '{}'
# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"}}

Authenticate with etcd for an authentication token using /v3/auth/authenticate:

# get the auth token for the root user
curl -L http://localhost:2379/v3/auth/authenticate \
  -X POST -d '{"name": "root", "password": "pass"}'
# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"1","raft_term":"2"},"token":"sssvIpwfnLAcWAQH.9"}

Set the Authorization header to the authentication token to fetch a key using authentication credentials:

curl -L http://localhost:2379/v3/kv/put \
  -H 'Authorization: sssvIpwfnLAcWAQH.9' \
  -X POST -d '{"key": "Zm9v", "value": "YmFy"}'
# {"header":{"cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"2","raft_term":"2"}}

Error responses

The gRPC gateway translates gRPC status into HTTP status codes and a JSON error body. Starting in etcd v3.6, the upgrade to grpc-gateway v2 changed error handling (see the v2 migration guide’s error-handling note ), and the gateway behavior now aligns with google.rpc.Status (code, message, details) as described in Google’s API error model . Historically, older grpc-gateway versions also included a top-level error field, but this field is not supported in etcd v3.6 and higher versions.

Clients should treat the HTTP status code as the primary indicator of success or failure. If a request fails, clients should rely on the message field as the primary source of error information and use any additional details for further context.

Swagger

Generated Swagger API definitions can be found at rpc.swagger.json .

5 - gRPC naming and discovery

go-grpc: for resolving gRPC endpoints with an etcd backend

etcd provides a gRPC resolver to support an alternative name system that fetches endpoints from etcd for discovering gRPC services. The underlying mechanism is based on watching updates to keys prefixed with the service name.

Note that this feature is experimental because it depends on the google.golang.org/grpc/resolver package, which is still experimental in grpc-go.

Using etcd discovery with go-grpc

The etcd client provides a gRPC resolver for resolving gRPC endpoints with an etcd backend. The resolver is initialized with an etcd client:

import (
	clientv3 "go.etcd.io/etcd/client/v3"
	etcdnaming "go.etcd.io/etcd/client/v3/naming/resolver"

	"google.golang.org/grpc"
)

...

cli, err := clientv3.NewFromURL("http://localhost:2379")
if err != nil {
    // ...
}
r, err := etcdnaming.NewBuilder(cli)
if err != nil {
    // ...
}
conn, gerr := grpc.NewClient("my-service", grpc.WithResolvers(r), ...)

Managing service endpoints

The etcd resolver treats all keys under the prefix of the resolution target following a “/” (e.g., “foo/bar/my-service/”) with JSON-encoded (historically go-grpc naming.Update) values as potential service endpoints. Endpoints are added to the service by creating new keys and removed from the service by deleting keys.

Adding an endpoint

New endpoints can be added to the service through etcdctl:

ETCDCTL_API=3 etcdctl put foo/bar/my-service/1.2.3.4 '{"Addr":"1.2.3.4"}'

The etcd client’s endpoints.Manager method can also register new endpoints with a key matching the Addr:


em := endpoints.NewManager(client, "foo/bar/my-service")
err := em.AddEndpoint(context.TODO(),"foo/bar/my-service/e1", endpoints.Endpoint{Addr:"1.2.3.4"})

To enable round-robin load balancing when dialing service with multiple endpoints, you can set up you connection with grpc internal round-robin load balancer:


conn, gerr := grpc.NewClient("etcd:///foo", grpc.WithResolvers(etcdResolver),
grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"}`))

Deleting an endpoint

Hosts can be deleted from the service through etcdctl:

ETCDCTL_API=3 etcdctl del foo/bar/my-service/1.2.3.4

The etcd client’s endpoints.Manager method also supports deleting endpoints:

em := endpoints.NewManager(client, "foo/bar/my-service")
err := em.DeleteEndpoint(context.TODO(), "foo/bar/my-service/e1")

Registering an endpoint with a lease

Registering an endpoint with a lease ensures that if the host can’t maintain a keepalive heartbeat (e.g., its machine fails), it will be removed from the service:

lease=`ETCDCTL_API=3 etcdctl lease grant 5 | cut -f2 -d' '`
ETCDCTL_API=3 etcdctl put --lease=$lease my-service/1.2.3.4 '{"Addr":"1.2.3.4"}'
ETCDCTL_API=3 etcdctl lease keep-alive $lease

In the golang:

em := endpoints.NewManager(client, "foo/bar/my-service")
err := em.AddEndpoint(context.TODO(), "foo/bar/my-service/e1", endpoints.Endpoint{Addr:"1.2.3.4"})

Atomically updating endpoints

If it’s desired to modify multiple endpoints in a single transaction, endpoints.Manager can be used directly:

em := endpoints.NewManager(c, "foo")

err := em.Update(context.TODO(), []*endpoints.UpdateWithOpts{
    endpoints.NewDeleteUpdateOpts("foo/bar/my-service/e1", endpoints.Endpoint{Addr: "1.2.3.4"}),
	endpoints.NewAddUpdateOpts("foo/bar/my-service/e1", endpoints.Endpoint{Addr: "1.2.3.14"})})

6 - Embedding etcd in a Go Application

Use etcd embed go package to run an etcd server within your application

The etcd embed go package provides a simple way to embed an etcd server directly into your application.

For more details, see the embed package documentation .

7 - System limits

etcd limits: requests and storage

Request size limit

etcd is designed to handle small key value pairs typical for metadata. Larger requests will work, but may increase the latency of other requests. By default, the maximum size of any request is 1.5 MiB. This limit is configurable through --max-request-bytes flag for etcd server.

Storage size limit

The default storage size limit is 2 GiB, configurable with --quota-backend-bytes flag. 8 GiB is a suggested maximum size for normal environments and etcd warns at startup if the configured value exceeds it.

8 - etcd features

using etcd features

This document provides an overview of etcd features to help users better understand the features and related deprecation process. If you are interested in knowing about how features are developed in the etcd, please see these development guidelines .

The etcd features fall into three stages, experimental, stable, and unsafe. You can get the list of features by running etcd --help.

Experimental

In order to get early feedback, any new feature is usually added as an experimental feature. The experimental feature can be identified by looking at the flag name, which should have --experimental as a prefix. Please consider the following points while using an experimental feature:

  • It might be buggy due to a lack of user testing. Enabling the feature may not work as expected.
  • It is disabled by default.
  • Support for such a feature may be dropped at any time without notice
    • It can be removed in the next minor or major release without following the feature deprecation policy unless it graduates to a stable future.
    • The project team would appreciate users reporting any issues related to experimental features. However, such issues may be given lower priorities compared to the issues related to stable featuers.
  • An experimental feature flag deprecates when it graduates to the stable stage. Users should start using a stable feature flag as soon as possible.

Stable

This is the most common stage of features in the etcd. A stable feature is characterized as below:

  • Supported as part of the supported releases of etcd.
  • May be enabled by default.
  • Discontinuation of support must follow the feature deprecation policy.

Unsafe

Unsafe features are rare and listed under the Unsafe feature: section in the etcd usage documentation. By default, they are disabled. They should be used with caution following documentation. An unsafe feature can be removed in the next minor or major release without following the feature deprecation policy.

Feature Deprecation

Experimental

An experimental feature deprecates when it graduates to the stable stage.

  • The experimental feature documentation will show a deprecation message with a recommendation to use a related stable feature flag. e.g. DEPRECATED. Use <feature-name> instead.
  • A deprecated feature will be removed in the following release.

Stable

As the project evolves, a stable feature may sometimes need to be deprecated and removed. When that happens,

  • The feature documentation will show a warning message before a planned release for deprecation. e.g. To be deprecated in <release>.. If a new feature is already planned to replace the To be deprecated feature, then the documentation will also provide a message saying so. e.g. Use <feature-name> instead..
  • The feature will be deprecated in the planned release. At that time, the feature documentation will show a deprecation message with a recommendation to use a related stable feature. e.g. DEPRECATED. Use <feature-name> instead.
  • A deprecated feature will be removed in the following release.

9 - API reference

Complete reference for the etcd v3 API

This API reference is autogenerated from the named .proto files.

service Auth (api/etcdserverpb/rpc.proto)
Method Request Type Response Type Description
AuthEnable AuthEnableRequest AuthEnableResponse AuthEnable enables authentication.
AuthDisable AuthDisableRequest AuthDisableResponse AuthDisable disables authentication.
AuthStatus AuthStatusRequest AuthStatusResponse AuthStatus displays authentication status.
Authenticate AuthenticateRequest AuthenticateResponse Authenticate processes an authenticate request.
UserAdd AuthUserAddRequest AuthUserAddResponse UserAdd adds a new user. User name cannot be empty.
UserGet AuthUserGetRequest AuthUserGetResponse UserGet gets detailed user information.
UserList AuthUserListRequest AuthUserListResponse UserList gets a list of all users.
UserDelete AuthUserDeleteRequest AuthUserDeleteResponse UserDelete deletes a specified user.
UserChangePassword AuthUserChangePasswordRequest AuthUserChangePasswordResponse UserChangePassword changes the password of a specified user.
UserGrantRole AuthUserGrantRoleRequest AuthUserGrantRoleResponse UserGrant grants a role to a specified user.
UserRevokeRole AuthUserRevokeRoleRequest AuthUserRevokeRoleResponse UserRevokeRole revokes a role of specified user.
RoleAdd AuthRoleAddRequest AuthRoleAddResponse RoleAdd adds a new role. Role name cannot be empty.
RoleGet AuthRoleGetRequest AuthRoleGetResponse RoleGet gets detailed role information.
RoleList AuthRoleListRequest AuthRoleListResponse RoleList gets lists of all roles.
RoleDelete AuthRoleDeleteRequest AuthRoleDeleteResponse RoleDelete deletes a specified role.
RoleGrantPermission AuthRoleGrantPermissionRequest AuthRoleGrantPermissionResponse RoleGrantPermission grants a permission of a specified key or range to a specified role.
RoleRevokePermission AuthRoleRevokePermissionRequest AuthRoleRevokePermissionResponse RoleRevokePermission revokes a key or range permission of a specified role.
service Cluster (api/etcdserverpb/rpc.proto)
Method Request Type Response Type Description
MemberAdd MemberAddRequest MemberAddResponse MemberAdd adds a member into the cluster.
MemberRemove MemberRemoveRequest MemberRemoveResponse MemberRemove removes an existing member from the cluster.
MemberUpdate MemberUpdateRequest MemberUpdateResponse MemberUpdate updates the member configuration.
MemberList MemberListRequest MemberListResponse MemberList lists all the members in the cluster.
MemberPromote MemberPromoteRequest MemberPromoteResponse MemberPromote promotes a member from raft learner (non-voting) to raft voting member.
service KV (api/etcdserverpb/rpc.proto)
Method Request Type Response Type Description
Range RangeRequest RangeResponse Range gets the keys in the range from the key-value store.
Put PutRequest PutResponse Put puts the given key into the key-value store. A put request increments the revision of the key-value store and generates one event in the event history.
DeleteRange DeleteRangeRequest DeleteRangeResponse DeleteRange deletes the given range from the key-value store. A delete request increments the revision of the key-value store and generates a delete event in the event history for every deleted key.
Txn TxnRequest TxnResponse Txn processes multiple requests in a single transaction. A txn request increments the revision of the key-value store and generates events with the same revision for every completed request. It is not allowed to modify the same key several times within one txn.
Compact CompactionRequest CompactionResponse Compact compacts the event history in the etcd key-value store. The key-value store should be periodically compacted or the event history will continue to grow indefinitely.
service Lease (api/etcdserverpb/rpc.proto)
Method Request Type Response Type Description
LeaseGrant LeaseGrantRequest LeaseGrantResponse LeaseGrant creates a lease which expires if the server does not receive a keepAlive within a given time to live period. All keys attached to the lease will be expired and deleted if the lease expires. Each expired key generates a delete event in the event history.
LeaseRevoke LeaseRevokeRequest LeaseRevokeResponse LeaseRevoke revokes a lease. All keys attached to the lease will expire and be deleted.
LeaseKeepAlive LeaseKeepAliveRequest LeaseKeepAliveResponse LeaseKeepAlive keeps the lease alive by streaming keep alive requests from the client to the server and streaming keep alive responses from the server to the client.
LeaseTimeToLive LeaseTimeToLiveRequest LeaseTimeToLiveResponse LeaseTimeToLive retrieves lease information.
LeaseLeases LeaseLeasesRequest LeaseLeasesResponse LeaseLeases lists all existing leases.
service Maintenance (api/etcdserverpb/rpc.proto)
Method Request Type Response Type Description
Alarm AlarmRequest AlarmResponse Alarm activates, deactivates, and queries alarms regarding cluster health.
Status StatusRequest StatusResponse Status gets the status of the member.
Defragment DefragmentRequest DefragmentResponse Defragment defragments a member’s backend database to recover storage space.
Hash HashRequest HashResponse Hash computes the hash of whole backend keyspace, including key, lease, and other buckets in storage. This is designed for testing ONLY! Do not rely on this in production with ongoing transactions, since Hash operation does not hold MVCC locks. Use “HashKV” API instead for “key” bucket consistency checks.
HashKV HashKVRequest HashKVResponse HashKV computes the hash of all MVCC keys up to a given revision. It only iterates “key” bucket in backend storage.
Snapshot SnapshotRequest SnapshotResponse Snapshot sends a snapshot of the entire backend from a member over a stream to a client.
MoveLeader MoveLeaderRequest MoveLeaderResponse MoveLeader requests current leader node to transfer its leadership to transferee.
Downgrade DowngradeRequest DowngradeResponse Downgrade requests downgrades, verifies feasibility or cancels downgrade on the cluster version. Supported since etcd 3.5.
service Watch (api/etcdserverpb/rpc.proto)
Method Request Type Response Type Description
Watch WatchRequest WatchResponse Watch watches for events happening or that have happened. Both input and output are streams; the input stream is for creating and canceling watchers and the output stream sends events. One watch RPC can watch on multiple key ranges, streaming events for several watches at once. The entire event history can be watched starting from the last compaction revision.
message AlarmMember (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
memberID memberID is the ID of the member associated with the raised alarm. uint64
alarm alarm is the type of alarm which has been raised. AlarmType
message AlarmRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
action action is the kind of alarm request to issue. The action may GET alarm statuses, ACTIVATE an alarm, or DEACTIVATE a raised alarm. AlarmAction
memberID memberID is the ID of the member associated with the alarm. If memberID is 0, the alarm request covers all members. uint64
alarm alarm is the type of alarm to consider for this request. AlarmType
message AlarmResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
alarms alarms is a list of alarms associated with the alarm request. (slice of) AlarmMember
message AuthDisableRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message AuthDisableResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthEnableRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message AuthEnableResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthRoleAddRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name name is the name of the role to add to the authentication system. string
message AuthRoleAddResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthRoleDeleteRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
role string
message AuthRoleDeleteResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthRoleGetRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
role string
message AuthRoleGetResponse (api/etcdserverpb/rpc.proto)
Field Description Type
header ResponseHeader
perm (slice of) authpb.Permission
message AuthRoleGrantPermissionRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name name is the name of the role which will be granted the permission. string
perm perm is the permission to grant to the role. authpb.Permission
message AuthRoleGrantPermissionResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthRoleListRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message AuthRoleListResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
roles (slice of) string
message AuthRoleRevokePermissionRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
role string
key bytes
range_end bytes
message AuthRoleRevokePermissionResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthStatusRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message AuthStatusResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
enabled bool
authRevision authRevision is the current revision of auth store uint64
message AuthUserAddRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name string
password string
options authpb.UserAddOptions
hashedPassword string
message AuthUserAddResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthUserChangePasswordRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name name is the name of the user whose password is being changed. string
password password is the new password for the user. Note that this field will be removed in the API layer. string
hashedPassword hashedPassword is the new password for the user. Note that this field will be initialized in the API layer. string
message AuthUserChangePasswordResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthUserDeleteRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name name is the name of the user to delete. string
message AuthUserDeleteResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthUserGetRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name string
message AuthUserGetResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
roles (slice of) string
message AuthUserGrantRoleRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
user user is the name of the user which should be granted a given role. string
role role is the name of the role to grant to the user. string
message AuthUserGrantRoleResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthUserListRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message AuthUserListResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
users (slice of) string
message AuthUserRevokeRoleRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name string
role string
message AuthUserRevokeRoleResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message AuthenticateRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
name string
password string
message AuthenticateResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
token token is an authorized token that can be used in succeeding RPCs string
message CompactionRequest (api/etcdserverpb/rpc.proto)

CompactionRequest compacts the key-value store up to a given revision. All superseded keys with a revision less than the compaction revision will be removed.

Field Description Type
(versionpb.etcd_version_msg) option
revision revision is the key-value store revision for the compaction operation. int64
physical physical is set so the RPC will wait until the compaction is physically applied to the local database such that compacted entries are totally removed from the backend database. bool
message CompactionResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message Compare (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
result result is logical comparison operation for this comparison. CompareResult
target target is the key-value field to inspect for the comparison. CompareTarget
key key is the subject key for the comparison operation. bytes
target_union oneof
version version is the version of the given key int64
create_revision create_revision is the creation revision of the given key int64
mod_revision mod_revision is the last modified revision of the given key. int64
value value is the value of the given key, in bytes. bytes
lease lease is the lease id of the given key. int64
range_end range_end compares the given target to all keys in the range [key, range_end). See RangeRequest for more details on key ranges. bytes
message DefragmentRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message DefragmentResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message DeleteRangeRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
key key is the first key to delete in the range. bytes
range_end range_end is the key following the last key to delete for the range [key, range_end). If range_end is not given, the range is defined to contain only the key argument. If range_end is one bit larger than the given key, then the range is all the keys with the prefix (the given key). If range_end is ‘\0’, the range is all keys greater than or equal to the key argument. bytes
prev_kv If prev_kv is set, etcd gets the previous key-value pairs before deleting it. The previous key-value pairs will be returned in the delete response. bool
message DeleteRangeResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
deleted deleted is the number of keys deleted by the delete range request. int64
prev_kvs if prev_kv is set in the request, the previous key-value pairs will be returned. (slice of) mvccpb.KeyValue
message DowngradeInfo (api/etcdserverpb/rpc.proto)
Field Description Type
enabled enabled indicates whether the cluster is enabled to downgrade. bool
targetVersion targetVersion is the target downgrade version. string
message DowngradeRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
action action is the kind of downgrade request to issue. The action may VALIDATE the target version, DOWNGRADE the cluster version, or CANCEL the current downgrading job. DowngradeAction
version version is the target version to downgrade. string
message DowngradeResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
version version is the current cluster version. string
message DowngradeVersionTestRequest (api/etcdserverpb/rpc.proto)

DowngradeVersionTestRequest is used for test only. The version in this request will be read as the WAL record version.If the downgrade target version is less than this version, then the downgrade(online) or migration(offline) isn’t safe, so shouldn’t be allowed.

Field Description Type
(versionpb.etcd_version_msg) option
ver string
message HashKVRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
revision revision is the key-value store revision for the hash operation. int64
message HashKVResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
hash hash is the hash value computed from the responding member’s MVCC keys up to a given revision. uint32
compact_revision compact_revision is the compacted revision of key-value store when hash begins. int64
hash_revision hash_revision is the revision up to which the hash is calculated. int64
message HashRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message HashResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
hash hash is the hash value computed from the responding member’s KV’s backend. uint32
message LeaseCheckpoint (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the lease ID to checkpoint. int64
remaining_TTL Remaining_TTL is the remaining time until expiry of the lease. int64
message LeaseCheckpointRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
checkpoints (slice of) LeaseCheckpoint
message LeaseCheckpointResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message LeaseGrantRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
TTL TTL is the advisory time-to-live in seconds. Expired lease will return -1. int64
ID ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID. int64
message LeaseGrantResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
ID ID is the lease ID for the granted lease. int64
TTL TTL is the server chosen lease time-to-live in seconds. int64
error string
message LeaseKeepAliveRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the lease ID for the lease to keep alive. int64
message LeaseKeepAliveResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
ID ID is the lease ID from the keep alive request. int64
TTL TTL is the new time-to-live for the lease. int64
message LeaseLeasesRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message LeaseLeasesResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
leases (slice of) LeaseStatus
message LeaseRevokeRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted. int64
message LeaseRevokeResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message LeaseStatus (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID int64
message LeaseTimeToLiveRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the lease ID for the lease. int64
keys keys is true to query all the keys attached to this lease. bool
message LeaseTimeToLiveResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
ID ID is the lease ID from the keep alive request. int64
TTL TTL is the remaining TTL in seconds for the lease; the lease will expire in under TTL+1 seconds. int64
grantedTTL GrantedTTL is the initial granted time in seconds upon lease creation/renewal. int64
keys Keys is the list of keys attached to this lease. (slice of) bytes
message Member (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the member ID for this member. uint64
name name is the human-readable name of the member. If the member is not started, the name will be an empty string. string
peerURLs peerURLs is the list of URLs the member exposes to the cluster for communication. (slice of) string
clientURLs clientURLs is the list of URLs the member exposes to clients for communication. If the member is not started, clientURLs will be empty. (slice of) string
isLearner isLearner indicates if the member is raft learner. bool
message MemberAddRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
peerURLs peerURLs is the list of URLs the added member will use to communicate with the cluster. (slice of) string
isLearner isLearner indicates if the added member is raft learner. bool
message MemberAddResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
member member is the member information for the added member. Member
members members is a list of all members after adding the new member. (slice of) Member
message MemberListRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
linearizable bool
message MemberListResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
members members is a list of all members associated with the cluster. (slice of) Member
message MemberPromoteRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the member ID of the member to promote. uint64
message MemberPromoteResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
members members is a list of all members after promoting the member. (slice of) Member
message MemberRemoveRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the member ID of the member to remove. uint64
message MemberRemoveResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
members members is a list of all members after removing the member. (slice of) Member
message MemberUpdateRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
ID ID is the member ID of the member to update. uint64
peerURLs peerURLs is the new list of URLs the member will use to communicate with the cluster. (slice of) string
message MemberUpdateResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
members members is a list of all members after updating the member. (slice of) Member
message MoveLeaderRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
targetID targetID is the node ID for the new leader. uint64
message MoveLeaderResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
message PutRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
key key is the key, in bytes, to put into the key-value store. bytes
value value is the value, in bytes, to associate with the key in the key-value store. bytes
lease lease is the lease ID to associate with the key in the key-value store. A lease value of 0 indicates no lease. int64
prev_kv If prev_kv is set, etcd gets the previous key-value pair before changing it. The previous key-value pair will be returned in the put response. bool
ignore_value If ignore_value is set, etcd updates the key using its current value. Returns an error if the key does not exist. bool
ignore_lease If ignore_lease is set, etcd updates the key using its current lease. Returns an error if the key does not exist. bool
message PutResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
prev_kv if prev_kv is set in the request, the previous key-value pair will be returned. mvccpb.KeyValue
message RangeRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
key key is the first key for the range. If range_end is not given, the request only looks up key. bytes
range_end range_end is the upper bound on the requested range [key, range_end). If range_end is ‘\0’, the range is all keys >= key. If range_end is key plus one (e.g., “aa”+1 == “ab”, “a\xff”+1 == “b”), then the range request gets all keys prefixed with key. If both key and range_end are ‘\0’, then the range request returns all keys. bytes
limit limit is a limit on the number of keys returned for the request. When limit is set to 0, it is treated as no limit. int64
revision revision is the point-in-time of the key-value store to use for the range. If revision is less or equal to zero, the range is over the newest key-value store. If the revision has been compacted, ErrCompacted is returned as a response. int64
sort_order sort_order is the order for returned sorted results. SortOrder
sort_target sort_target is the key-value field to use for sorting. SortTarget
serializable serializable sets the range request to use serializable member-local reads. Range requests are linearizable by default; linearizable requests have higher latency and lower throughput than serializable requests but reflect the current consensus of the cluster. For better performance, in exchange for possible stale reads, a serializable range request is served locally without needing to reach consensus with other nodes in the cluster. bool
keys_only keys_only when set returns only the keys and not the values. bool
count_only count_only when set returns only the count of the keys in the range. bool
min_mod_revision min_mod_revision is the lower bound for returned key mod revisions; all keys with lesser mod revisions will be filtered away. int64
max_mod_revision max_mod_revision is the upper bound for returned key mod revisions; all keys with greater mod revisions will be filtered away. int64
min_create_revision min_create_revision is the lower bound for returned key create revisions; all keys with lesser create revisions will be filtered away. int64
max_create_revision max_create_revision is the upper bound for returned key create revisions; all keys with greater create revisions will be filtered away. int64
message RangeResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
kvs kvs is the list of key-value pairs matched by the range request. kvs is empty when count is requested. (slice of) mvccpb.KeyValue
more more indicates if there are more keys to return in the requested range. bool
count count is set to the actual number of keys within the range when requested. Unlike Kvs, it is unaffected by limits and filters (e.g., Min/Max, Create/Modify, Revisions) and reflects the full count within the specified range. int64
message RequestOp (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
request request is a union of request types accepted by a transaction. oneof
request_range RangeRequest
request_put PutRequest
request_delete_range DeleteRangeRequest
request_txn TxnRequest
message ResponseHeader (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
cluster_id cluster_id is the ID of the cluster which sent the response. uint64
member_id member_id is the ID of the member which sent the response. uint64
revision revision is the key-value store revision when the request was applied, and it’s unset (so 0) in case of calls not interacting with key-value store. For watch progress responses, the header.revision indicates progress. All future events received in this stream are guaranteed to have a higher revision number than the header.revision number. int64
raft_term raft_term is the raft term when the request was applied. uint64
message ResponseOp (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
response response is a union of response types returned by a transaction. oneof
response_range RangeResponse
response_put PutResponse
response_delete_range DeleteRangeResponse
response_txn TxnResponse
message SnapshotRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message SnapshotResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header header has the current key-value store information. The first header in the snapshot stream indicates the point in time of the snapshot. ResponseHeader
remaining_bytes remaining_bytes is the number of blob bytes to be sent after this message uint64
blob blob contains the next chunk of the snapshot in the snapshot stream. bytes
version local version of server that created the snapshot. In cluster with binaries with different version, each cluster can return different result. Informs which etcd server version should be used when restoring the snapshot. string
message StatusRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
message StatusResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
version version is the cluster protocol version used by the responding member. string
dbSize dbSize is the size of the backend database physically allocated, in bytes, of the responding member. int64
leader leader is the member ID which the responding member believes is the current leader. uint64
raftIndex raftIndex is the current raft committed index of the responding member. uint64
raftTerm raftTerm is the current raft term of the responding member. uint64
raftAppliedIndex raftAppliedIndex is the current raft applied index of the responding member. uint64
errors errors contains alarm/health information and status. (slice of) string
dbSizeInUse dbSizeInUse is the size of the backend database logically in use, in bytes, of the responding member. int64
isLearner isLearner indicates if the member is raft learner. bool
storageVersion storageVersion is the version of the db file. It might be updated with delay in relationship to the target cluster version. string
dbSizeQuota dbSizeQuota is the configured etcd storage quota in bytes (the value passed to etcd instance by flag –quota-backend-bytes) int64
downgradeInfo downgradeInfo indicates if there is downgrade process. DowngradeInfo
message TxnRequest (api/etcdserverpb/rpc.proto)

From google paxosdb paper: Our implementation hinges around a powerful primitive which we call MultiOp. All other database operations except for iteration are implemented as a single call to MultiOp. A MultiOp is applied atomically and consists of three components: 1. A list of tests called guard. Each test in guard checks a single entry in the database. It may check for the absence or presence of a value, or compare with a given value. Two different tests in the guard may apply to the same or different entries in the database. All tests in the guard are applied and MultiOp returns the results. If all tests are true, MultiOp executes t op (see item 2 below), otherwise it executes f op (see item 3 below). 2. A list of database operations called t op. Each operation in the list is either an insert, delete, or lookup operation, and applies to a single database entry. Two different operations in the list may apply to the same or different entries in the database. These operations are executed if guard evaluates to true. 3. A list of database operations called f op. Like t op, but executed if guard evaluates to false.

Field Description Type
(versionpb.etcd_version_msg) option
compare compare is a list of predicates representing a conjunction of terms. If the comparisons succeed, then the success requests will be processed in order, and the response will contain their respective responses in order. If the comparisons fail, then the failure requests will be processed in order, and the response will contain their respective responses in order. (slice of) Compare
success success is a list of requests which will be applied when compare evaluates to true. (slice of) RequestOp
failure failure is a list of requests which will be applied when compare evaluates to false. (slice of) RequestOp
message TxnResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
succeeded succeeded is set to true if the compare evaluated to true or false otherwise. bool
responses responses is a list of responses corresponding to the results from applying success if succeeded is true or failure if succeeded is false. (slice of) ResponseOp
message WatchCancelRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
watch_id watch_id is the watcher id to cancel so that no more events are transmitted. int64
message WatchCreateRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
key key is the key to register for watching. bytes
range_end range_end is the end of the range [key, range_end) to watch. If range_end is not given, only the key argument is watched. If range_end is equal to ‘\0’, all keys greater than or equal to the key argument are watched. If the range_end is one bit larger than the given key, then all keys with the prefix (the given key) will be watched. bytes
start_revision start_revision is an optional revision to watch from (inclusive). No start_revision is “now”. int64
progress_notify progress_notify is set so that the etcd server will periodically send a WatchResponse with no events to the new watcher if there are no recent events. It is useful when clients wish to recover a disconnected watcher starting from a recent known revision. The etcd server may decide how often it will send notifications based on current load. bool
filters filters filter the events at server side before it sends back to the watcher. (slice of) FilterType
prev_kv If prev_kv is set, created watcher gets the previous KV before the event happens. If the previous KV is already compacted, nothing will be returned. bool
watch_id If watch_id is provided and non-zero, it will be assigned to this watcher. Since creating a watcher in etcd is not a synchronous operation, this can be used ensure that ordering is correct when creating multiple watchers on the same stream. Creating a watcher with an ID already in use on the stream will cause an error to be returned. int64
fragment fragment enables splitting large revisions into multiple watch responses. bool
message WatchProgressRequest (api/etcdserverpb/rpc.proto)

Requests the a watch stream progress status be sent in the watch response stream as soon as possible.

Field Description Type
(versionpb.etcd_version_msg) option
message WatchRequest (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
request_union request_union is a request to either create a new watcher or cancel an existing watcher. oneof
create_request WatchCreateRequest
cancel_request WatchCancelRequest
progress_request WatchProgressRequest
message WatchResponse (api/etcdserverpb/rpc.proto)
Field Description Type
(versionpb.etcd_version_msg) option
header ResponseHeader
watch_id watch_id is the ID of the watcher that corresponds to the response. int64
created created is set to true if the response is for a create watch request. The client should record the watch_id and expect to receive events for the created watcher from the same stream. All events sent to the created watcher will attach with the same watch_id. bool
canceled canceled is set to true if the response is for a cancel watch request or if the start_revision has already been compacted. No further events will be sent to the canceled watcher. bool
compact_revision compact_revision is set to the minimum index if a watcher tries to watch at a compacted index. This happens when creating a watcher at a compacted revision or the watcher cannot catch up with the progress of the key-value store. The client should treat the watcher as canceled and should not try to create any watcher with the same start_revision again. int64
cancel_reason cancel_reason indicates the reason for canceling the watcher. string
fragment framgment is true if large watch response was split over multiple responses. bool
events (slice of) mvccpb.Event
message Event (api/mvccpb/kv.proto)
Field Description Type
type type is the kind of event. If type is a PUT, it indicates new data has been stored to the key. If type is a DELETE, it indicates the key was deleted. EventType
kv kv holds the KeyValue for the event. A PUT event contains current kv pair. A PUT event with kv.Version=1 indicates the creation of a key. A DELETE/EXPIRE event contains the deleted key with its modification revision set to the revision of deletion. KeyValue
prev_kv prev_kv holds the key-value pair before the event happens. KeyValue
message KeyValue (api/mvccpb/kv.proto)
Field Description Type
key key is the key in bytes. An empty key is not allowed. bytes
create_revision create_revision is the revision of last creation on this key. int64
mod_revision mod_revision is the revision of last modification on this key. int64
version version is the version of the key. A deletion resets the version to zero and any modification of the key increases its version. int64
value value is the value held by the key, in bytes. bytes
lease lease is the ID of the lease that attached to key. When the attached lease expires, the key will be deleted. If lease is 0, then no lease is attached to the key. int64
message Lease (server/lease/leasepb/lease.proto)
Field Description Type
ID int64
TTL int64
RemainingTTL int64
message LeaseInternalRequest (server/lease/leasepb/lease.proto)
Field Description Type
LeaseTimeToLiveRequest etcdserverpb.LeaseTimeToLiveRequest
message LeaseInternalResponse (server/lease/leasepb/lease.proto)
Field Description Type
LeaseTimeToLiveResponse etcdserverpb.LeaseTimeToLiveResponse
message Permission (api/authpb/auth.proto)

Permission is a single entity

Field Description Type
permType Type
key bytes
range_end bytes
message Role (api/authpb/auth.proto)

Role is a single entry in the bucket authRoles

Field Description Type
name bytes
keyPermission (slice of) Permission
message User (api/authpb/auth.proto)

User is a single entry in the bucket authUsers

Field Description Type
name bytes
password bytes
roles (slice of) string
options UserAddOptions
message UserAddOptions (api/authpb/auth.proto)
Field Description Type
no_password bool

10 - API reference: concurrency

Reference for etcd concurrency APIs

This API reference is autogenerated from the named .proto files.

service Lock (server/etcdserver/api/v3lock/v3lockpb/v3lock.proto)

The lock service exposes client-side locking facilities as a gRPC interface.

Method Request Type Response Type Description
Lock LockRequest LockResponse Lock acquires a distributed shared lock on a given named lock. On success, it will return a unique key that exists so long as the lock is held by the caller. This key can be used in conjunction with transactions to safely ensure updates to etcd only occur while holding lock ownership. The lock is held until Unlock is called on the key or the lease associate with the owner expires.
Unlock UnlockRequest UnlockResponse Unlock takes a key returned by Lock and releases the hold on lock. The next Lock caller waiting for the lock will then be woken up and given ownership of the lock.
message LockRequest (server/etcdserver/api/v3lock/v3lockpb/v3lock.proto)
Field Description Type
name name is the identifier for the distributed shared lock to be acquired. bytes
lease lease is the ID of the lease that will be attached to ownership of the lock. If the lease expires or is revoked and currently holds the lock, the lock is automatically released. Calls to Lock with the same lease will be treated as a single acquisition; locking twice with the same lease is a no-op. int64
message LockResponse (server/etcdserver/api/v3lock/v3lockpb/v3lock.proto)
Field Description Type
header etcdserverpb.ResponseHeader
key key is a key that will exist on etcd for the duration that the Lock caller owns the lock. Users should not modify this key or the lock may exhibit undefined behavior. bytes
message UnlockRequest (server/etcdserver/api/v3lock/v3lockpb/v3lock.proto)
Field Description Type
key key is the lock ownership key granted by Lock. bytes
message UnlockResponse (server/etcdserver/api/v3lock/v3lockpb/v3lock.proto)
Field Description Type
header etcdserverpb.ResponseHeader
service Election (server/etcdserver/api/v3election/v3electionpb/v3election.proto)

The election service exposes client-side election facilities as a gRPC interface.

Method Request Type Response Type Description
Campaign CampaignRequest CampaignResponse Campaign waits to acquire leadership in an election, returning a LeaderKey representing the leadership if successful. The LeaderKey can then be used to issue new values on the election, transactionally guard API requests on leadership still being held, and resign from the election.
Proclaim ProclaimRequest ProclaimResponse Proclaim updates the leader’s posted value with a new value.
Leader LeaderRequest LeaderResponse Leader returns the current election proclamation, if any.
Observe LeaderRequest LeaderResponse Observe streams election proclamations in-order as made by the election’s elected leaders.
Resign ResignRequest ResignResponse Resign releases election leadership so other campaigners may acquire leadership on the election.
message CampaignRequest (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
name name is the election’s identifier for the campaign. bytes
lease lease is the ID of the lease attached to leadership of the election. If the lease expires or is revoked before resigning leadership, then the leadership is transferred to the next campaigner, if any. int64
value value is the initial proclaimed value set when the campaigner wins the election. bytes
message CampaignResponse (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
header etcdserverpb.ResponseHeader
leader leader describes the resources used for holding leadereship of the election. LeaderKey
message LeaderKey (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
name name is the election identifier that corresponds to the leadership key. bytes
key key is an opaque key representing the ownership of the election. If the key is deleted, then leadership is lost. bytes
rev rev is the creation revision of the key. It can be used to test for ownership of an election during transactions by testing the key’s creation revision matches rev. int64
lease lease is the lease ID of the election leader. int64
message LeaderRequest (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
name name is the election identifier for the leadership information. bytes
message LeaderResponse (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
header etcdserverpb.ResponseHeader
kv kv is the key-value pair representing the latest leader update. mvccpb.KeyValue
message ProclaimRequest (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
leader leader is the leadership hold on the election. LeaderKey
value value is an update meant to overwrite the leader’s current value. bytes
message ProclaimResponse (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
header etcdserverpb.ResponseHeader
message ResignRequest (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
leader leader is the leadership to relinquish by resignation. LeaderKey
message ResignResponse (server/etcdserver/api/v3election/v3electionpb/v3election.proto)
Field Description Type
header etcdserverpb.ResponseHeader
message Event (api/mvccpb/kv.proto)
Field Description Type
type type is the kind of event. If type is a PUT, it indicates new data has been stored to the key. If type is a DELETE, it indicates the key was deleted. EventType
kv kv holds the KeyValue for the event. A PUT event contains current kv pair. A PUT event with kv.Version=1 indicates the creation of a key. A DELETE/EXPIRE event contains the deleted key with its modification revision set to the revision of deletion. KeyValue
prev_kv prev_kv holds the key-value pair before the event happens. KeyValue
message KeyValue (api/mvccpb/kv.proto)
Field Description Type
key key is the key in bytes. An empty key is not allowed. bytes
create_revision create_revision is the revision of last creation on this key. int64
mod_revision mod_revision is the revision of last modification on this key. int64
version version is the version of the key. A deletion resets the version to zero and any modification of the key increases its version. int64
value value is the value held by the key, in bytes. bytes
lease lease is the ID of the lease that attached to key. When the attached lease expires, the key will be deleted. If lease is 0, then no lease is attached to the key. int64