Skip to content

Commit

Permalink
delete PullOption (#1507)
Browse files Browse the repository at this point in the history
  • Loading branch information
pongad authored Jan 6, 2017
1 parent 5614adb commit b0cac2f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,64 +77,6 @@ public static ListOption pageToken(String pageToken) {
}
}

/** Class for specifying options for pulling messages. */
final class PullOption extends Option {

private static final long serialVersionUID = 4792164134340316582L;

enum OptionType implements Option.OptionType {
EXECUTOR_FACTORY,
MAX_QUEUED_CALLBACKS;

@SuppressWarnings("unchecked")
<T> T get(Map<Option.OptionType, ?> options) {
return (T) options.get(this);
}

Integer getInteger(Map<Option.OptionType, ?> options) {
return get(options);
}

ExecutorFactory<ExecutorService> getExecutorFactory(Map<Option.OptionType, ?> options) {
return get(options);
}
}

private PullOption(Option.OptionType option, Object value) {
super(option, value);
}

/**
* Returns an option to specify the maximum number of messages that can be queued in the message
* consumer at any time. Queued messages are already pulled messages that are either waiting to
* be processed or being processed. Queued messages will have their acknowledge deadline renewed
* until they are acknowledged or "nacked". If not provided, at most 100 messages can be in the
* queue.
*/
public static PullOption maxQueuedCallbacks(int maxQueuedCallbacks) {
return new PullOption(OptionType.MAX_QUEUED_CALLBACKS, maxQueuedCallbacks);
}

/**
* Returns an option to specify the executor used to execute message processor callbacks. The
* executor determines the number of messages that can be processed at the same time. If not
* provided, a single-threaded executor is used to execute message processor callbacks.
*
* <p>The {@link ExecutorFactory} object can be used to handle creation and release of the
* executor, possibly reusing existing executors. {@link ExecutorFactory#get()} is called when
* the message consumer is created. {@link ExecutorFactory#release(ExecutorService)} is called
* when the message consumer is closed.
*
* <p>For the created option to be serializable, the provided executor factory should implement
* {@link java.io.Serializable}.
*
* @param executorFactory the executor factory.
*/
public static PullOption executorFactory(ExecutorFactory executorFactory) {
return new PullOption(OptionType.EXECUTOR_FACTORY, executorFactory);
}
}

/**
* Creates a new topic.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.cloud.GrpcServiceOptions.ExecutorFactory;
import com.google.cloud.pubsub.PubSub.ListOption;
import com.google.cloud.pubsub.PubSub.PullOption;

import org.easymock.EasyMock;
import org.junit.Test;
Expand All @@ -43,17 +42,4 @@ public void testListOption() {
assertEquals(PAGE_SIZE, listOption.getValue());
assertEquals(ListOption.OptionType.PAGE_SIZE, listOption.getOptionType());
}

@Test
@SuppressWarnings("unchecked")
public void testPullOptions() {
// max queued callbacks
PullOption pullOption = PullOption.maxQueuedCallbacks(MAX_QUEUED_CALLBACKS);
assertEquals(MAX_QUEUED_CALLBACKS, pullOption.getValue());
assertEquals(PullOption.OptionType.MAX_QUEUED_CALLBACKS, pullOption.getOptionType());
ExecutorFactory executorFactory = EasyMock.createStrictMock(ExecutorFactory.class);
pullOption = PullOption.executorFactory(executorFactory);
assertSame(executorFactory, pullOption.getValue());
assertEquals(PullOption.OptionType.EXECUTOR_FACTORY, pullOption.getOptionType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.cloud.NoCredentials;
import com.google.cloud.Restorable;
import com.google.cloud.pubsub.PubSub.ListOption;
import com.google.cloud.pubsub.PubSub.PullOption;
import java.io.Serializable;
import java.util.concurrent.ScheduledExecutorService;

Expand All @@ -41,9 +40,6 @@ public class SerializationTest extends BaseSerializationTest {
new Topic(PUB_SUB, new TopicInfo.BuilderImpl(TOPIC_INFO));
private static final ListOption PAGE_TOKEN_OPTION = ListOption.pageToken("cursor");
private static final ListOption PAGE_SIZE_OPTION = ListOption.pageSize(42);
private static final PullOption MAX_QUEUED_CALLBACKS_OPTION = PullOption.maxQueuedCallbacks(42);
private static final PullOption EXECUTOR_FACTORY_OPTION =
PullOption.executorFactory(new TestExecutorFactory());

public static class TestExecutorFactory
implements ExecutorFactory<ScheduledExecutorService>, Serializable {
Expand Down Expand Up @@ -91,8 +87,6 @@ protected Serializable[] serializableObjects() {
TOPIC,
PAGE_TOKEN_OPTION,
PAGE_SIZE_OPTION,
MAX_QUEUED_CALLBACKS_OPTION,
EXECUTOR_FACTORY_OPTION
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.google.cloud.Identity;
import com.google.cloud.Policy;
import com.google.cloud.Role;
import com.google.cloud.pubsub.PubSub.PullOption;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Futures;
Expand Down

0 comments on commit b0cac2f

Please sign in to comment.