MCPcopy
hub / github.com/IBM/sarama / Consumer

Interface Consumer

consumer.go:54–97  ·  consumer.go::Consumer

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.

Source from the content-addressed store, hash-verified

52// on a consumer to avoid leaks, it will not be garbage-collected automatically when it passes out of
53// scope.
54type 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
100const partitionConsumersBatchTimeout = 100 * time.Millisecond

Callers 63

TopicsMethod · 0.65
PartitionsMethod · 0.65
consumeMsgsFunction · 0.95
TestFuncTxnProduceFunction · 0.95
TestFuncTxnProduceFunction · 0.95

Implementers 2

consumerconsumer.go
Consumermocks/consumer.go

Calls

no outgoing calls

Tested by

no test coverage detected