Skip to content

Instantly share code, notes, and snippets.

@gardnervickers
Created May 13, 2015 02:27
Show Gist options
  • Save gardnervickers/6cb4dce9c01a60f1ee1a to your computer and use it in GitHub Desktop.
Save gardnervickers/6cb4dce9c01a60f1ee1a to your computer and use it in GitHub Desktop.
(ns flat-workflow.functions.sample-functions)
(defn ^{:batch-size 10 :onyx? true} increment-age [segment]
(update-in segment [:age] inc))
(defn ^{:batch-size 10 :onyx? true} legal?
"hello world"
[age segment]
age)
(defn onyx-fn? [var]
(and (fn? @var) (:onyx? (meta var))))
(defn arglist [var]
(:arglists (meta var)))
(defn function->catalog [var]
(if (onyx-fn? var)
(let [args (filter #(not= % "segment") (map str (first (arglist var))))
name (str (:name (meta var)))
batch-size (:batch-size (meta var))
ns (str (:ns (meta var)))
key (keyword ns name)
doc (:doc (meta var))]
{:onyx/name (keyword name)
:onyx/params (vec (map keyword args))
:onyx/fn key
:onyx/type :function
:onyx/batch-size 10
:onyx/doc doc})))
(defn ns->catalog [ns-symbol]
(mapv function->catalog (vals (ns-interns ns-symbol))))
(map function->catalog
(vals (ns-interns 'flat-workflow.functions.sample-functions)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment