Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide gRPC class in lease and replace ListenableFuture with #63

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions src/main/java/com/coreos/jetcd/EtcdLease.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.coreos.jetcd;

import com.coreos.jetcd.api.LeaseGrantResponse;
import com.coreos.jetcd.api.LeaseKeepAliveResponse;
import com.coreos.jetcd.api.LeaseRevokeResponse;
import com.coreos.jetcd.data.EtcdHeader;
import com.coreos.jetcd.lease.Lease;
import com.coreos.jetcd.lease.NoSuchLeaseException;
import com.google.common.util.concurrent.ListenableFuture;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
Expand All @@ -19,47 +19,47 @@ public interface EtcdLease {
* @param ttl ttl value, unit seconds
* @return
*/
ListenableFuture<LeaseGrantResponse> grant(long ttl);
CompletableFuture<Lease> grant(long ttl);

/**
* revoke one lease and the key bind to this lease will be removed
*
* @param leaseId id of the lease to revoke
* @param lease lease to revoke
* @return
*/
ListenableFuture<LeaseRevokeResponse> revoke(long leaseId);
CompletableFuture<EtcdHeader> revoke(Lease lease);

/**
* keep alive one lease in background
*
* @param leaseId id of lease to set handler
* @param lease lease to set handler
* @param etcdLeaseHandler the handler for the lease, this value can be null
*/
void keepAlive(long leaseId, EtcdLeaseHandler etcdLeaseHandler);
void keepAlive(Lease lease, EtcdLeaseHandler etcdLeaseHandler);

/**
* cancel keep alive for lease in background
*
* @param leaseId id of lease
*/
void cancelKeepAlive(long leaseId) throws ExecutionException, InterruptedException;
* @param lease lease
*/
void cancelKeepAlive(Lease lease) throws ExecutionException, InterruptedException;

/**
* keep alive one lease only once
*
* @param leaseId id of lease to keep alive once
* @param lease lease to keep alive once
* @return The keep alive response
*/
ListenableFuture<LeaseKeepAliveResponse> keepAliveOnce(long leaseId);
CompletableFuture<EtcdHeader> keepAliveOnce(Lease lease);

/**
* set EtcdLeaseHandler for lease
*
* @param leaseId id of the lease to set handler
* @param lease the lease to set handler
* @param etcdLeaseHandler the handler for the lease
* @throws NoSuchLeaseException if lease do not exist
*/
void setEtcdLeaseHandler(long leaseId, EtcdLeaseHandler etcdLeaseHandler) throws NoSuchLeaseException;
void setEtcdLeaseHandler(Lease lease, EtcdLeaseHandler etcdLeaseHandler) throws NoSuchLeaseException;

/**
* Init the request stream to etcd
Expand All @@ -78,6 +78,7 @@ public interface EtcdLease {

/**
* It hints the state of the keep alive service.
*
* @return whether the keep alive service is running.
*/
boolean isKeepAliveServiceRunning();
Expand Down
Loading