Skip to content

Commit

Permalink
pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
pongad committed Jan 30, 2017
1 parent 546d670 commit 6ee024f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 44 deletions.
2 changes: 1 addition & 1 deletion google-cloud-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>0.0.28-SNAPSHOT</version>
<version>0.0.28</version>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

package com.google.cloud.logging.spi;

import com.google.api.gax.core.Function;
import com.google.api.gax.core.RpcFuture;
import com.google.api.gax.grpc.ApiException;
import com.google.api.gax.grpc.ChannelProvider;
import com.google.api.gax.grpc.ExecutorProvider;
import com.google.api.gax.grpc.FixedChannelProvider;
import com.google.api.gax.grpc.FixedExecutorProvider;
import com.google.api.gax.grpc.ProviderManager;
import com.google.api.gax.grpc.RpcFuture;
import com.google.api.gax.grpc.UnaryCallSettings;
import com.google.cloud.GrpcServiceOptions.ExecutorFactory;
import com.google.cloud.NoCredentials;
Expand Down Expand Up @@ -155,7 +156,7 @@ private static <V> Future<V> translate(
}
return from.catching(
ApiException.class,
new RpcFuture.Function<ApiException, V>() {
new Function<ApiException, V>() {
@Override
public V apply(ApiException exception) {
if (returnNullOnSet.contains(exception.getStatusCode().value())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

package com.google.cloud.pubsub.spi;

import com.google.api.gax.core.ForwardingRpcFuture;
import com.google.api.gax.core.Function;
import com.google.api.gax.core.RpcFuture;
import com.google.api.gax.core.RpcFutureCallback;
import com.google.api.gax.grpc.ApiException;
import com.google.api.gax.grpc.ChannelProvider;
import com.google.api.gax.grpc.ExecutorProvider;
import com.google.api.gax.grpc.FixedChannelProvider;
import com.google.api.gax.grpc.FixedExecutorProvider;
import com.google.api.gax.grpc.ProviderManager;
import com.google.api.gax.grpc.RpcFuture;
import com.google.api.gax.grpc.RpcFutureCallback;
import com.google.api.gax.grpc.UnaryCallSettings;
import com.google.cloud.GrpcServiceOptions.ExecutorFactory;
import com.google.cloud.NoCredentials;
Expand Down Expand Up @@ -65,11 +67,8 @@
import io.grpc.netty.NettyChannelBuilder;
import java.io.IOException;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.joda.time.Duration;

public class DefaultPubSubRpc implements PubSubRpc {
Expand Down Expand Up @@ -107,48 +106,19 @@ protected ChannelProvider getChannelProvider() {
}
}

private static final class PullFutureImpl
private static final class PullFutureImpl extends ForwardingRpcFuture<PullResponse>
implements PullFuture {

private final RpcFuture<PullResponse> delegate;

PullFutureImpl(RpcFuture<PullResponse> delegate) {
this.delegate = delegate;
}

@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return delegate.cancel(mayInterruptIfRunning);
}

@Override
public PullResponse get() throws InterruptedException, ExecutionException {
return delegate.get();
}

@Override
public PullResponse get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate.get(timeout, unit);
}

@Override
public boolean isCancelled() {
return delegate.isCancelled();
}

@Override
public boolean isDone() {
return delegate.isDone();
super(delegate);
}

@Override
public void addCallback(final PullCallback callback) {
delegate.addCallback(
addCallback(
new RpcFutureCallback<PullResponse>() {
@Override
public void onSuccess(PullResponse result) {
callback.success(result);
public void onSuccess(PullResponse response) {
callback.success(response);
}

@Override
Expand Down Expand Up @@ -211,7 +181,7 @@ private static <V> RpcFuture<V> translate(
}
return from.catching(
ApiException.class,
new RpcFuture.Function<ApiException, V>() {
new Function<ApiException, V>() {
@Override
public V apply(ApiException exception) {
if (returnNullOnSet.contains(exception.getStatusCode().value())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.google.pubsub.v1.PullResponse;
import com.google.pubsub.v1.Subscription;
import com.google.pubsub.v1.Topic;

import java.util.concurrent.Future;

public interface PubSubRpc extends AutoCloseable {
Expand Down

0 comments on commit 6ee024f

Please sign in to comment.