Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Add previous result in step functions, mocked functions #43

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
150 changes: 102 additions & 48 deletions README.md

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
org.clojure/clojurescript {:mvn/version "1.10.520"}
expound {:mvn/version "0.7.2"}
org.clojure/test.check {:mvn/version "0.10.0-alpha3" :exclusions [org.clojure/clojure]}
orchestra {:mvn/version "2018.12.06-2"}}}
:pack {:extra-deps {pack/pack.alpha {:git/url "https://github.com/juxt/pack.alpha.git"
:sha "90a84a01c365fdac224bf4eef6e9c8e1d018a29e"}}}
:deploy {:extra-deps {deps-deploy {:git/url "https://github.com/slipset/deps-deploy.git"
:sha "388481b808fc7b1a27951ad2725cac0ba10adb6b"}}}}}
orchestra {:mvn/version "2018.12.06-2"}
thheller/shadow-cljs {:mvn/version "2.8.59"}}}
:example {:extra-paths ["examples"]}}}
62 changes: 32 additions & 30 deletions examples/fonda/simple.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
(ns fonda.example.simple
(ns fonda.simple
(:require [clojure.string :as str]
[fonda.core :as fonda]
[goog.object :as gobj]))
[fonda.core.specs]
[goog.object :as gobj]
[orchestra-cljs.spec.test :as orchestra]
[process]))

(orchestra/instrument)

(defn response->loads-of-data
[ctx]
Expand All @@ -15,31 +20,28 @@
(str/split dd "-")
(str/join " " dd)))

(fonda/execute
{}

[{:processor (fn [ctx]
{:status 200
:headers {"Content-Type" "application/json"}
:body {:data :loads-of}})
:name "get-loads-of-data"
:path [:http-response]}

{:processor response->loads-of-data ;; Pure function - ctx in - ctx out
:name "response-processor"
:path [:data]}]

{:data :very-little}

;; on-success
(fn [ctx]
(println "Before we had" (-> ctx :data :before to-str) "data,"
"but now we have" (-> ctx :data :after to-str) "it."))

;; on-anomaly
(fn [anomaly]
(println "Anomaly detected in the matrix"))

;; on-exception
(fn [exception]
(println (gobj/get exception "message"))))
(defn main [& cli-args]
ElChache marked this conversation as resolved.
Show resolved Hide resolved
(fonda/execute
{:ctx {:data :very-little}}

[{:processor (fn [ctx]
{:status 200
:headers {"Content-Type" "application/json"}
:body {:data :loads-of}})
:name "get-loads-of-data"
:path [:http-response]}

{:processor response->loads-of-data ;; Pure function - ctx in - ctx out
:name "response-processor"
:path [:data]}]

;; on-exception
(fn [ctx exception]
(println (gobj/get exception "message"))
(process/exit 1))

;; on-success
(fn [ctx last-step-result]
(println "Before we had" (-> ctx :data :before to-str) "data,"
"but now we have" (-> ctx :data :after to-str) "it.")
(process/exit 0))))
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "An async pipeline approach to functional core - imperative shell.",
"license": "Unlicense",
"contributors": [
"David Cerezo Iñigo <dcerezoi@protonmail.com",
"David Cerezo Iñigo <davidcerezoinigo@gmail.com",
"Andrea Richiardi <[email protected]>",
"Sebastian Schulz"
],
Expand Down
63 changes: 0 additions & 63 deletions pom.xml

This file was deleted.

43 changes: 0 additions & 43 deletions scripts/deploy-jar

This file was deleted.

58 changes: 0 additions & 58 deletions scripts/git-revision

This file was deleted.

43 changes: 0 additions & 43 deletions scripts/install-jar

This file was deleted.

54 changes: 0 additions & 54 deletions scripts/repl

This file was deleted.

Loading