• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

etcd-io/jetcd: etcd java client

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

etcd-io/jetcd

开源软件地址:

https://github.com/etcd-io/jetcd

开源编程语言:

Java 99.5%

开源软件介绍:

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 8 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, plesase 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 recommmonds 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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap