|
@@ -572,10 +572,7 @@ func (bc *brokerConsumer) subscriptionConsumer() {
|
|
|
|
|
|
|
|
|
for newSubscriptions := range bc.newSubscriptions {
|
|
|
- for _, child := range newSubscriptions {
|
|
|
- bc.subscriptions[child] = none{}
|
|
|
- Logger.Printf("consumer/broker/%d added subscription to %s/%d\n", bc.broker.ID(), child.topic, child.partition)
|
|
|
- }
|
|
|
+ bc.updateSubscriptions(newSubscriptions)
|
|
|
|
|
|
if len(bc.subscriptions) == 0 {
|
|
|
|
|
@@ -601,8 +598,12 @@ func (bc *brokerConsumer) subscriptionConsumer() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (bc *brokerConsumer) handleResponses() {
|
|
|
-
|
|
|
+func (bc *brokerConsumer) updateSubscriptions(newSubscriptions []*partitionConsumer) {
|
|
|
+ for _, child := range newSubscriptions {
|
|
|
+ bc.subscriptions[child] = none{}
|
|
|
+ Logger.Printf("consumer/broker/%d added subscription to %s/%d\n", bc.broker.ID(), child.topic, child.partition)
|
|
|
+ }
|
|
|
+
|
|
|
for child := range bc.subscriptions {
|
|
|
select {
|
|
|
case <-child.dying:
|
|
@@ -610,37 +611,44 @@ func (bc *brokerConsumer) handleResponses() {
|
|
|
close(child.trigger)
|
|
|
delete(bc.subscriptions, child)
|
|
|
default:
|
|
|
- result := child.responseResult
|
|
|
- child.responseResult = nil
|
|
|
-
|
|
|
- switch result {
|
|
|
- case nil:
|
|
|
- break
|
|
|
- case errTimedOut:
|
|
|
- Logger.Printf("consumer/broker/%d abandoned subscription to %s/%d because consuming was taking too long\n",
|
|
|
- bc.broker.ID(), child.topic, child.partition)
|
|
|
- delete(bc.subscriptions, child)
|
|
|
- case ErrOffsetOutOfRange:
|
|
|
-
|
|
|
-
|
|
|
- child.sendError(result)
|
|
|
- Logger.Printf("consumer/%s/%d shutting down because %s\n", child.topic, child.partition, result)
|
|
|
- close(child.trigger)
|
|
|
- delete(bc.subscriptions, child)
|
|
|
- case ErrUnknownTopicOrPartition, ErrNotLeaderForPartition, ErrLeaderNotAvailable:
|
|
|
-
|
|
|
- Logger.Printf("consumer/broker/%d abandoned subscription to %s/%d because %s\n",
|
|
|
- bc.broker.ID(), child.topic, child.partition, result)
|
|
|
- child.trigger <- none{}
|
|
|
- delete(bc.subscriptions, child)
|
|
|
- default:
|
|
|
-
|
|
|
- child.sendError(result)
|
|
|
- Logger.Printf("consumer/broker/%d abandoned subscription to %s/%d because %s\n",
|
|
|
- bc.broker.ID(), child.topic, child.partition, result)
|
|
|
- child.trigger <- none{}
|
|
|
- delete(bc.subscriptions, child)
|
|
|
- }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (bc *brokerConsumer) handleResponses() {
|
|
|
+
|
|
|
+ for child := range bc.subscriptions {
|
|
|
+ result := child.responseResult
|
|
|
+ child.responseResult = nil
|
|
|
+
|
|
|
+ switch result {
|
|
|
+ case nil:
|
|
|
+ break
|
|
|
+ case errTimedOut:
|
|
|
+ Logger.Printf("consumer/broker/%d abandoned subscription to %s/%d because consuming was taking too long\n",
|
|
|
+ bc.broker.ID(), child.topic, child.partition)
|
|
|
+ delete(bc.subscriptions, child)
|
|
|
+ case ErrOffsetOutOfRange:
|
|
|
+
|
|
|
+
|
|
|
+ child.sendError(result)
|
|
|
+ Logger.Printf("consumer/%s/%d shutting down because %s\n", child.topic, child.partition, result)
|
|
|
+ close(child.trigger)
|
|
|
+ delete(bc.subscriptions, child)
|
|
|
+ case ErrUnknownTopicOrPartition, ErrNotLeaderForPartition, ErrLeaderNotAvailable:
|
|
|
+
|
|
|
+ Logger.Printf("consumer/broker/%d abandoned subscription to %s/%d because %s\n",
|
|
|
+ bc.broker.ID(), child.topic, child.partition, result)
|
|
|
+ child.trigger <- none{}
|
|
|
+ delete(bc.subscriptions, child)
|
|
|
+ default:
|
|
|
+
|
|
|
+ child.sendError(result)
|
|
|
+ Logger.Printf("consumer/broker/%d abandoned subscription to %s/%d because %s\n",
|
|
|
+ bc.broker.ID(), child.topic, child.partition, result)
|
|
|
+ child.trigger <- none{}
|
|
|
+ delete(bc.subscriptions, child)
|
|
|
}
|
|
|
}
|
|
|
}
|