Created
May 13, 2015 02:27
-
-
Save gardnervickers/6cb4dce9c01a60f1ee1a to your computer and use it in GitHub Desktop.
This file contains 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
(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