Skip to content

Commit

Permalink
etcd add connect time
Browse files Browse the repository at this point in the history
  • Loading branch information
Alonexc committed Apr 10, 2024
1 parent 466ada3 commit 60209c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@

package org.apache.eventmesh.dashboard.core.function.SDK.config;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CreateEtcdConfig implements CreateSDKConfig {

private String etcdServerAddress;

private Long connectTime;

@Override
public String getUniqueKey() {
return etcdServerAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateEtcdConfig;
import org.apache.eventmesh.dashboard.core.function.SDK.config.CreateSDKConfig;

import java.time.Duration;
import java.util.AbstractMap.SimpleEntry;

import io.etcd.jetcd.Client;
Expand All @@ -39,6 +40,7 @@ public SimpleEntry<String, KV> createClient(CreateSDKConfig clientConfig) {
try {
final Client client = Client.builder()
.endpoints(getSplitEndpoints(etcdConfig))
.connectTimeout(Duration.ofSeconds(etcdConfig.getConnectTime()))
.build();
kvClient = client.getKVClient();
} catch (EtcdException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public class EtcdSDKCreateOperationTest {

@Test
void testCreateClient() {
final CreateEtcdConfig etcdConfig = new CreateEtcdConfig();
etcdConfig.setEtcdServerAddress(url);
final CreateEtcdConfig etcdConfig = CreateEtcdConfig.builder()
.etcdServerAddress(url)
.connectTime(10L)
.build();
// etcdConfig.setEtcdServerAddress(url);
SimpleEntry<String, KV> simpleEntry = null;
try {
simpleEntry = etcdSDKOperation.createClient(etcdConfig);
Expand Down

0 comments on commit 60209c4

Please sign in to comment.