Consumer manages PartitionConsumers which process Kafka messages from brokers. You MUST call Close() on a consumer to avoid leaks, it will not be garbage-collected automatically when it passes out of scope.
| 52 | // on a consumer to avoid leaks, it will not be garbage-collected automatically when it passes out of |
| 53 | // scope. |
| 54 | type Consumer interface { |
| 55 | // Topics returns the set of available topics as retrieved from the cluster |
| 56 | // metadata. This method is the same as Client.Topics(), and is provided for |
| 57 | // convenience. |
| 58 | Topics() ([]string, error) |
| 59 | |
| 60 | // Partitions returns the sorted list of all partition IDs for the given topic. |
| 61 | // This method is the same as Client.Partitions(), and is provided for convenience. |
| 62 | Partitions(topic string) ([]int32, error) |
| 63 | |
| 64 | // ConsumePartition creates a PartitionConsumer on the given topic/partition with |
| 65 | // the given offset. It will return an error if this Consumer is already consuming |
| 66 | // on the given topic/partition. Offset can be a literal offset, or OffsetNewest |
| 67 | // or OffsetOldest |
| 68 | ConsumePartition(topic string, partition int32, offset int64) (PartitionConsumer, error) |
| 69 | |
| 70 | // HighWaterMarks returns the current high water marks for each topic and partition. |
| 71 | // Consistency between partitions is not guaranteed since high water marks are updated separately. |
| 72 | HighWaterMarks() map[string]map[int32]int64 |
| 73 | |
| 74 | // Close shuts down the consumer. It must be called after all child |
| 75 | // PartitionConsumers have already been closed. |
| 76 | Close() error |
| 77 | |
| 78 | // Pause suspends fetching from the requested partitions. Future calls to the broker will not return any |
| 79 | // records from these partitions until they have been resumed using Resume()/ResumeAll(). |
| 80 | // Note that this method does not affect partition subscription. |
| 81 | // In particular, it does not cause a group rebalance when automatic assignment is used. |
| 82 | Pause(topicPartitions map[string][]int32) |
| 83 | |
| 84 | // Resume resumes specified partitions which have been paused with Pause()/PauseAll(). |
| 85 | // New calls to the broker will return records from these partitions if there are any to be fetched. |
| 86 | Resume(topicPartitions map[string][]int32) |
| 87 | |
| 88 | // PauseAll suspends fetching from all partitions. Future calls to the broker will not return any |
| 89 | // records from these partitions until they have been resumed using Resume()/ResumeAll(). |
| 90 | // Note that this method does not affect partition subscription. |
| 91 | // In particular, it does not cause a group rebalance when automatic assignment is used. |
| 92 | PauseAll() |
| 93 | |
| 94 | // ResumeAll resumes all partitions which have been paused with Pause()/PauseAll(). |
| 95 | // New calls to the broker will return records from these partitions if there are any to be fetched. |
| 96 | ResumeAll() |
| 97 | } |
| 98 | |
| 99 | // max time to wait for more partition subscriptions |
| 100 | const partitionConsumersBatchTimeout = 100 * time.Millisecond |
no outgoing calls
no test coverage detected