Skip to content

Instantly share code, notes, and snippets.

@prismofeverything
Created July 9, 2019 22:38
Show Gist options
  • Save prismofeverything/09086f8712ca41683ccd27d69f9a8116 to your computer and use it in GitHub Desktop.
Save prismofeverything/09086f8712ca41683ccd27d69f9a8116 to your computer and use it in GitHub Desktop.
(defn iteration->seq
[iteration]
(seq
(reify java.lang.Iterable
(iterator [this]
(reify java.util.Iterator
(hasNext [this] (.hasNext iteration))
(next [this] (.next iteration))
(remove [this] (.remove iteration)))))))
(defn logs-seq
"Convert a docker-client ^LogStream to a seq of lines."
[logs]
(let [it (iteration->seq logs)
content (map #(.toString (.decode StandardCharsets/UTF_8 (.content ^LogMessage %))) it)]
(mapcat #(string/split % #"\n") content)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment