This project exposes the etcd gRPC API (KV, Lease, Lock, Maintenance, Watch, Cluster).
Inspired from: https://github.com/etcd-io/jetcd
This project is experimental, use at your own risk.
For Quarkus version 3.4.1+
<dependency>
<groupId>ro.gs1</groupId>
<artifactId>quarkus-etcd-client</artifactId>
<version>${current.version}</version>
</dependency>
# --- Configuration per client, replace "client-name" (quotes included) ---
# etcd server host.
# Defaults to 'localhost'
quarkus.etcd."client-name".host=localhost
# etcd server port.
# Defaults to '2379'.
quarkus.etcd."client-name".port=2379
# Client username for authentication with server.
# No default.
quarkus.etcd."client-name".name=my_username
# Client password for authentication with server.
# No default.
quarkus.etcd."client-name".password=my_password
# Timeout for authentication with the server.
# Defaults to 5s default.
quarkus.etcd."client-name".authentication-timeout=5s
# Vert.x Channel default '9223372036854775807s'.
quarkus.etcd."client-name".keep-alive-time=5s
# Vert.x Channel default '20s'.
quarkus.etcd."client-name".keep-alive-timeout=20s
# Vert.x Channel default 'false'.
quarkus.etcd."client-name".keep-alive-without-calls=false
# Vert.x Channel default '4194304' (4MiB).
quarkus.etcd."client-name".max-inbound-message-size=4194304
# Vert.x Channel default ''.
quarkus.etcd."client-name".authority=
# Vert.x Channel default 'pick_first'.
quarkus.etcd."client-name".default-load-balancing-policy=pick_first
# --- Certificate authentication configuration per client name, optional ---
# Path to the JKS file, classpath or file.
# No default.
quarkus.etcd."client-name".ssl-config.key-store.path=
# Password of the JKS.
# No default.
quarkus.etcd."client-name".ssl-config.key-store.password=
# If there are multiple aliases in the JKS, choose one.
# No default.
quarkus.etcd."client-name".ssl-config.key-store.alias=
# Password of the alias.
# No default.
quarkus.etcd."client-name".ssl-config.key-store.alias-password=
# --- SSL/TLS configuration per client name, optional ---
# Path to the JKS file, classpath or file.
# No default.
quarkus.etcd."client-name".ssl-config.trust-store.path=
# Password of the JKS.
# No default.
quarkus.etcd."client-name".ssl-config.trust-store.password=
You can use @EtcdClient in your code to inject etcd stub:
public class Foo {
@EtcdClient("clientName")
EtcdClientChannel client;
}
public class Foo {
@EtcdClient("clientName")
EtcdClientChannel client;
public Uni<PutResponse> bar() {
return client.getKVClient().put(PutRequest.newBuilder()
.setKey(ByteString.copyFrom("key", StandardCharsets.UTF_8))
.setValue(ByteString.copyFrom("value", StandardCharsets.UTF_8))
.build());
}
}
All the above are Mutiny backed stubs and are using a single gRPC channel per client.
There is support for authentication:
- Token authentication with username and password,
- Certificate authentication;
Also, TLS/SLL is supported.
You can also inject the stubs with @GrpcClient. If choose this way you need to use the io.quarkus.grpc configuration (Quarkus Documentation):
public class Foo {
@GrpcClient("etcd")
KV kvClient;
}
quarkus-etcd-client is under the Apache 2.0 license. See the LICENSE file for details.