Github user liurenjie1024 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1835#discussion_r93555404
  
    --- Diff: 
external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/internal/fetcher/KafkaRecordsFetchers.java
 ---
    @@ -0,0 +1,41 @@
    +package org.apache.storm.kafka.spout.internal.fetcher;
    +
    +import org.apache.kafka.clients.consumer.ConsumerRebalanceListener;
    +import org.apache.kafka.clients.consumer.KafkaConsumer;
    +import org.apache.storm.kafka.spout.KafkaPartitionReader;
    +import org.apache.storm.kafka.spout.KafkaPartitionReaders;
    +import org.apache.storm.kafka.spout.KafkaSpout;
    +import org.apache.storm.kafka.spout.KafkaSpoutConfig;
    +import org.apache.storm.task.TopologyContext;
    +
    +import java.util.concurrent.TimeUnit;
    +
    +/**
    + * Created by liurenjie on 19/12/2016.
    + */
    +public final class KafkaRecordsFetchers {
    +    public static <K, V> KafkaRecordsFetcher<K, V> 
kafkaRecordsFetcherOf(KafkaSpoutConfig kafkaSpoutConfig,
    +                                                                         
KafkaConsumer<K, V> consumer,
    +                                                                         
TopologyContext context,
    +                                                                         
ConsumerRebalanceListener rebalanceListener) {
    +        if (kafkaSpoutConfig.getManualPartitionAssignment()) {
    --- End diff --
    
    1. The if conditions are wrapped in a factory method so adding more cases 
will not pollute other components.
    2. The construction of instances can only happen in the open method since 
it needs topology context.
    3. Interface is used to hide the client from implementation details and I 
don't think our approach here violated the rule.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to