Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add oldest-topic-offset to simple consumer #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add oldest-topic-offset to simple consumer
aeneaswiener committed Mar 24, 2014
commit 8339ac17d01c5555f0e505fe1cf842127afe1e76
7 changes: 7 additions & 0 deletions src/clj_kafka/consumer/simple.clj
Original file line number Diff line number Diff line change
@@ -37,3 +37,10 @@
hm (java.util.HashMap. {tp pori})]
(let [response (.getOffsetsBefore consumer (OffsetRequest. hm (kafka.api.OffsetRequest/CurrentVersion) "clj-kafka-id"))]
(first (.offsets response topic partition)))))

(defn oldest-topic-offset [consumer topic partition]
(let [tp (TopicAndPartition. topic partition)
pori (PartitionOffsetRequestInfo. -2 1)
hm (java.util.HashMap. {tp pori})]
(let [response (.getOffsetsBefore consumer (OffsetRequest. hm (kafka.api.OffsetRequest/CurrentVersion) "clj-kafka-id"))]
(first (.offsets response topic partition)))))