MCPcopy Index your code
hub / github.com/etcd-io/jetcd

github.com/etcd-io/jetcd @jetcd-0.8.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release jetcd-0.8.6 ↗ · + Follow
1,124 symbols 4,915 edges 164 files 353 documented · 31%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

jetcd - A Java Client for etcd

Build Status License Maven Central Javadocs

jetcd is the official java client for etcd v3.

Note: jetcd is work-in-progress and may break backward compatibility.

Java Versions

Java 11 or above is required.

Download

Maven

<dependency>
  <groupId>io.etcd</groupId>
  <artifactId>jetcd-core</artifactId>
  <version>${jetcd-version}</version>
</dependency>

Development snapshots are available in Sonatypes's snapshot repository.

Gradle

dependencies {
    implementation "io.etcd:jetcd-core:$jetcd-version"
}

Usage

// create client using endpoints
Client client = Client.builder().endpoints("http://etcd0:2379", "http://etcd1:2379", "http://etcd2:2379").build();
// create client using target which enable using any name resolution mechanism provided
// by grpc-java (i.e. dns:///foo.bar.com:2379)
Client client = Client.builder().target("ip:///etcd0:2379,etcd1:2379,etcd2:2379").build();
KV kvClient = client.getKVClient();
ByteSequence key = ByteSequence.from("test_key".getBytes());
ByteSequence value = ByteSequence.from("test_value".getBytes());

// put the key-value
kvClient.put(key, value).get();

// get the CompletableFuture
CompletableFuture<GetResponse> getFuture = kvClient.get(key);

// get the value from CompletableFuture
GetResponse response = getFuture.get();

// delete the key
kvClient.delete(key).get();

To build one ssl secured client, refer to secured client config.

For full etcd v3 API, pleases refer to the official API documentation.

Examples

The jetcd-ctl is a standalone projects that show usage of jetcd.

Launcher

The io.etcd:jetcd-test offers a convenient utility to programmatically start & stop an isolated etcd server. This can be very useful e.g. for integration testing, like so:

import io.etcd.jetcd.Client;
import io.etcd.jetcd.test.EtcdClusterExtension;
import org.junit.jupiter.api.extension.RegisterExtension;

@RegisterExtension
public static final EtcdClusterExtension cluster = EtcdClusterExtension.builder()
        .withNodes(1)
        .build();

Client client = Client.builder().endpoints(cluster.clientEndpoints()).build();

This launcher uses the Testcontainers framework. For more info and prerequisites visit testcontainers.org.

Versioning

The project follows Semantic Versioning.

The current major version is zero (0.y.z). Anything may change at any time. The public API should not be considered stable.

Build from source

The project can be built with Gradle:

./gradlew compileJava

Running tests

The project is tested against a three node etcd setup started with the Launcher (above) :

$ ./gradlew test

Troubleshooting

It recommends building the project before running tests so that you have artifacts locally. It will solve some problems if the latest snapshot hasn't been uploaded or network issues.

Contact

Contributing

See CONTRIBUTING for details on submitting patches and the contribution workflow.

License

jetcd is under the Apache 2.0 license. See the LICENSE file for details.

Extension points exported contracts — how you extend this code

CloseableClient (Interface)
(no doc) [11 implementers]
jetcd-core/src/main/java/io/etcd/jetcd/support/CloseableClient.java
EtcdCluster (Interface)
(no doc) [1 implementers]
jetcd-launcher/src/main/java/io/etcd/jetcd/launcher/EtcdCluster.java
Response (Interface)
represents a generic Jetcd response. [2 implementers]
jetcd-core/src/main/java/io/etcd/jetcd/Response.java
Election (Interface)
Interface of leader election client talking to etcd. [2 implementers]
jetcd-core/src/main/java/io/etcd/jetcd/Election.java
Cluster (Interface)
Interface of cluster client talking to etcd. [2 implementers]
jetcd-core/src/main/java/io/etcd/jetcd/Cluster.java
Lock (Interface)
Interface of Lock talking to etcd. [2 implementers]
jetcd-core/src/main/java/io/etcd/jetcd/Lock.java

Core symbols most depended-on inside this repo

get
called by 512
jetcd-core/src/main/java/io/etcd/jetcd/KV.java
build
called by 146
jetcd-core/src/main/java/io/etcd/jetcd/ClientBuilder.java
newBuilder
called by 79
jetcd-core/src/main/java/io/etcd/jetcd/options/PutOption.java
getBytes
called by 65
jetcd-core/src/main/java/io/etcd/jetcd/ByteSequence.java
getHeader
called by 62
jetcd-core/src/main/java/io/etcd/jetcd/Response.java
from
called by 62
jetcd-core/src/main/java/io/etcd/jetcd/ByteSequence.java
put
called by 55
jetcd-core/src/main/java/io/etcd/jetcd/KV.java
size
called by 55
jetcd-core/src/main/java/io/etcd/jetcd/ByteSequence.java

Shape

Method 925
Class 173
Interface 18
Enum 8

Languages

Java100%

Modules by API surface

jetcd-core/src/main/java/io/etcd/jetcd/options/GetOption.java36 symbols
jetcd-core/src/main/java/io/etcd/jetcd/impl/LeaseImpl.java33 symbols
jetcd-core/src/main/java/io/etcd/jetcd/ClientBuilder.java32 symbols
jetcd-test/src/main/java/io/etcd/jetcd/test/EtcdClusterExtension.java26 symbols
jetcd-core/src/main/java/io/etcd/jetcd/options/WatchOption.java26 symbols
jetcd-core/src/test/java/io/etcd/jetcd/impl/WatchUnitTest.java23 symbols
jetcd-launcher/src/main/java/io/etcd/jetcd/launcher/EtcdContainer.java22 symbols
jetcd-core/src/main/java/io/etcd/jetcd/op/Op.java20 symbols
jetcd-core/src/main/java/io/etcd/jetcd/impl/WatchImpl.java19 symbols
jetcd-core/src/test/java/io/etcd/jetcd/impl/KVTest.java17 symbols
jetcd-core/src/test/java/io/etcd/jetcd/impl/KVNamespaceTest.java17 symbols
jetcd-core/src/main/java/io/etcd/jetcd/impl/AuthImpl.java17 symbols

For agents

$ claude mcp add jetcd \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page