This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require [clojure.data.xml :as xml]) | |
(import [java.io FileInputStream] | |
[java.util.zip GZIPInputStream] | |
[org.apache.commons.compress.compressors.gzip GzipCompressorInputStream] | |
[org.apache.commons.compress.archivers.tar TarArchiveInputStream TarArchiveEntry]) | |
(defn get-s3-file-stream [bucket key] | |
(-> (s3/get-object {:endpoint "eu-west-1"} | |
:bucket-name bucket | |
:key key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn -main [& args] | |
(.addShutdownHook (Runtime/getRuntime) | |
(Thread. (fn [] | |
(println "Shutting down application")))) | |
(while true | |
(Thread/sleep 500))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn m-error-handling [f] | |
(fn [& args] | |
(try | |
(let [res (apply f args)] | |
(if res | |
(right res) | |
(left {:message (str "nil returned calling " f " with " args)}))) | |
(catch Exception e | |
(left {:exception e :message (str "Exception thrown calling " f " with " args)}))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn with-error-handling [f] | |
(fn [& args] | |
(try | |
(if-let [res (apply f args)] | |
[res nil] | |
[nil {:message (str "Had nil returned calling " f " with " args)}] | |
(catch Exception e | |
[nil {:exception e :message (str "Had exception calling " f " with " args)}])))) | |
(defn our-comp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn with-error-handling [f] | |
(fn [& args] | |
(try | |
(let [res (apply f args)] | |
(if-not res | |
(log/error (str "Had nil returned calling " f " with " args))) | |
res) | |
(catch Exception e | |
(log/error e "An exception was thrown processing: " args) | |
(airbrake/notify config/airbrake e) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn something [x] | |
x) | |
(defn fun [x] | |
(something) | |
x) | |
(fact "something" | |
(fun 5) => 5 | |
(provided |