Skip to content

Instantly share code, notes, and snippets.

@l1x

l1x/test.clj Secret

Created February 26, 2015 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l1x/836b23fe864dd0db1259 to your computer and use it in GitHub Desktop.
Save l1x/836b23fe864dd0db1259 to your computer and use it in GitHub Desktop.
;works but only if (count streams) => 1
(defn messages
""
[^ArrayList streams]
(log/info "#streams" (count streams))
(let [ [^KafkaStream stream & _] streams ]
(map message-to-vec (lazy-messages (.iterator stream)))))
;does not work because it tries to get
;all of the messages from the first stream before moving on to the next
(defn messages-let
""
[^ArrayList streams]
(log/info "#streams" (count streams))
(for [ ^KafkaStream stream streams ]
(map message-to-vec (lazy-messages (.iterator stream)))))
;how can i do
;[stream stream stream ..... stream]
; =>
;(message-first-stream message-second-stream message-third-stream ..... message-nth-stream
; message-first-stream......message-nth-stream)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment