Skip to content

Commit

Permalink
change EtcdWatchImpl constract interface
Browse files Browse the repository at this point in the history
  • Loading branch information
StupidHod committed Dec 2, 2016
1 parent 5e16176 commit 20c19b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/coreos/jetcd/EtcdClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class EtcdClient {
private final Supplier<EtcdMaintenance> maintenanceClient;
private final Supplier<EtcdCluster> clusterClient;
private final Supplier<EtcdLease> leaseClient;
private final Supplier<EtcdWatch> watchClient;

public EtcdClient(EtcdClientBuilder builder) throws ConnectException, AuthFailedException {
this(Optional.empty(), builder);
Expand Down Expand Up @@ -62,6 +63,7 @@ private EtcdClient(Optional<ManagedChannelBuilder<?>> channelBuilder, EtcdClient
this.maintenanceClient = Suppliers.memoize(() -> new EtcdMaintenanceImpl(channel, token));
this.clusterClient = Suppliers.memoize(() -> new EtcdClusterImpl(channel, token));
this.leaseClient = Suppliers.memoize(() -> new EtcdLeaseImpl(channel, token));
this.watchClient = Suppliers.memoize(() -> new EtcdWatchImpl(channel, token));
}

// ************************
Expand All @@ -88,6 +90,10 @@ public EtcdLease getLeaseClient() {
return this.leaseClient.get();
}

public EtcdWatch getWatchClient() {
return this.watchClient.get();
}

public void close() {
channel.shutdownNow();
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/coreos/jetcd/EtcdWatchImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import com.coreos.jetcd.options.WatchOption;
import com.coreos.jetcd.watch.WatchCreateException;
import com.google.protobuf.ByteString;
import io.grpc.ManagedChannel;
import io.grpc.stub.StreamObserver;
import javafx.util.Pair;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.*;

import static com.coreos.jetcd.EtcdUtil.apiToClientEvents;
Expand All @@ -30,8 +32,8 @@ public class EtcdWatchImpl implements EtcdWatch {
private ConcurrentLinkedQueue<Pair<WatcherImpl, CompletableFuture<Watcher>>> pendingCreateWatchers = new ConcurrentLinkedQueue<>();
private Map<Long, CompletableFuture<Boolean>> pendingCancelFutures = new ConcurrentHashMap<>();

public EtcdWatchImpl(WatchGrpc.WatchStub watchStub) {
this.watchStub = watchStub;
public EtcdWatchImpl(ManagedChannel channel, Optional<String> token) {
this.watchStub = EtcdClientUtil.configureStub(WatchGrpc.newStub(channel), token);
}

/**
Expand Down

0 comments on commit 20c19b5

Please sign in to comment.