浏览代码

Return an error if the topic/partition is already consumed.

Willem van Bergen 10 年之前
父节点
当前提交
29c4ebd656
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      mocks/consumer.go

+ 4 - 0
mocks/consumer.go

@@ -47,6 +47,10 @@ func (c *Consumer) ConsumePartition(topic string, partition int32, offset int64)
 	}
 	}
 
 
 	pc := c.partitionConsumers[topic][partition]
 	pc := c.partitionConsumers[topic][partition]
+	if pc.consumed {
+		return nil, sarama.ConfigurationError("The topic/partition is already being consumed")
+	}
+
 	pc.consumed = true
 	pc.consumed = true
 	go pc.handleExpectations()
 	go pc.handleExpectations()
 	return pc, nil
 	return pc, nil