use of io.etcd.jetcd.api.LeaderRequest in project jetcd by coreos.
the class ElectionImpl method leader.
@Override
public CompletableFuture<LeaderResponse> leader(ByteSequence electionName) {
checkNotNull(electionName, "election name should not be null");
LeaderRequest request = LeaderRequest.newBuilder().setName(Util.prefixNamespace(electionName, namespace)).build();
return completable(stub.leader(request), r -> new LeaderResponse(r, namespace), this::convertException);
}
use of io.etcd.jetcd.api.LeaderRequest in project jetcd by coreos.
the class ElectionImpl method observe.
@Override
public void observe(ByteSequence electionName, Listener listener) {
checkNotNull(electionName, "election name should not be null");
checkNotNull(listener, "listener should not be null");
LeaderRequest request = LeaderRequest.newBuilder().setName(ByteString.copyFrom(electionName.getBytes())).build();
stub.observe(request).handler(value -> listener.onNext(new LeaderResponse(value, namespace))).endHandler(ignored -> listener.onCompleted()).exceptionHandler(error -> listener.onError(EtcdExceptionFactory.toEtcdException(error)));
}
Aggregations