Skip to content

Instantly share code, notes, and snippets.

@KirinDave
Created August 2, 2012 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KirinDave/05477f0c92eec4f9c4fb to your computer and use it in GitHub Desktop.
Save KirinDave/05477f0c92eec4f9c4fb to your computer and use it in GitHub Desktop.
Ugh
(defmacro single-key-aggregate-writer [name update-builder table]
`(defbolt ~name [] [~'tuple ~'collector]
(let [~'count-maps (tfield "count-maps")]
(try
(doseq [[~'agg-id ~'count-map] ~'count-maps]
(let [~'update-map (~update-builder ~'count-map)]
(dynamodb/update-item base/aws-credential ~table ~'agg-id ~'update-map)))
(ack! ~'collector ~'tuple)
(catch Exception ~'e
(log/error (str "Exception commiting to " ~table) (seq (.getStackTrace ~'e)))
(log/error ~'e)
(fail! ~'collector ~'tuple))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment