From b204471db677a1d2498b49efffab211093b453ca Mon Sep 17 00:00:00 2001 From: Alex Redington Date: Thu, 7 Dec 2023 13:40:04 -0500 Subject: [PATCH 1/3] Allow running the sync engine with a return on a channel --- src/nodely/api/v0.clj | 1 + src/nodely/engine/lazy.clj | 5 +++++ test/nodely/api_test.clj | 16 +++++++++++++++- test/nodely/engine/lazy_test.clj | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/nodely/api/v0.clj b/src/nodely/api/v0.clj index bb2be57..883a218 100644 --- a/src/nodely/api/v0.clj +++ b/src/nodely/api/v0.clj @@ -68,6 +68,7 @@ :or {engine :core-async.lazy-scheduling} :as opts}] (case engine + :sync.lazy (nodely.engine.lazy/eval-key-channel env k) :core-async.lazy-scheduling (lazy-scheduling/eval-key-channel env k opts) :applicative.core-async (nodely.engine.applicative/eval-key-contextual env k (assoc opts ::applicative/context applicative.core-async/context))))) diff --git a/src/nodely/engine/lazy.clj b/src/nodely/engine/lazy.clj index 2489d10..61bb1bd 100644 --- a/src/nodely/engine/lazy.clj +++ b/src/nodely/engine/lazy.clj @@ -1,6 +1,7 @@ (ns nodely.engine.lazy (:refer-clojure :exclude [eval resolve]) (:require + [clojure.core.async :as async] [nodely.data :as data] [nodely.engine.core :as core])) @@ -12,6 +13,10 @@ [env k] (data/get-value (eval env k) k)) +(defn eval-key-channel + [env k] + (async/thread (eval-key env k))) + (defn eval-node [node env] (eval-key (assoc env ::target node) ::target)) diff --git a/test/nodely/api_test.clj b/test/nodely/api_test.clj index d394a92..251f6b5 100644 --- a/test/nodely/api_test.clj +++ b/test/nodely/api_test.clj @@ -1,7 +1,21 @@ (ns nodely.api-test (:refer-clojure :exclude [cond]) (:require - [clojure.test :refer :all])) + [clojure.core.async :as async] + [clojure.test :refer :all] + [nodely.api.v0 :as api :refer [>value >leaf eval-key-channel]])) + +(def env {:x (>value 2) + :y (>value 3) + :z (>leaf (+ ?x ?y))}) + +(deftest eval-key-channel-test + (testing "returning a result to a channel with :sync.lazy" + (is (= 5 (async/ Date: Thu, 7 Dec 2023 15:49:26 -0300 Subject: [PATCH 2/3] lint fix --- test/nodely/api_test.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/nodely/api_test.clj b/test/nodely/api_test.clj index 251f6b5..f696cd6 100644 --- a/test/nodely/api_test.clj +++ b/test/nodely/api_test.clj @@ -3,7 +3,7 @@ (:require [clojure.core.async :as async] [clojure.test :refer :all] - [nodely.api.v0 :as api :refer [>value >leaf eval-key-channel]])) + [nodely.api.v0 :as api :refer [>leaf >value eval-key-channel]])) (def env {:x (>value 2) :y (>value 3) From f49ab39eea0dd41bfd998f4e3fd10200e67a60b1 Mon Sep 17 00:00:00 2001 From: Alex Redington Date: Thu, 7 Dec 2023 13:40:04 -0500 Subject: [PATCH 3/3] Allow running the sync engine with a return on a channel --- src/nodely/api/v0.clj | 1 + src/nodely/engine/lazy.clj | 5 +++++ test/nodely/api_test.clj | 16 +++++++++++++++- test/nodely/engine/lazy_test.clj | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/nodely/api/v0.clj b/src/nodely/api/v0.clj index bb2be57..883a218 100644 --- a/src/nodely/api/v0.clj +++ b/src/nodely/api/v0.clj @@ -68,6 +68,7 @@ :or {engine :core-async.lazy-scheduling} :as opts}] (case engine + :sync.lazy (nodely.engine.lazy/eval-key-channel env k) :core-async.lazy-scheduling (lazy-scheduling/eval-key-channel env k opts) :applicative.core-async (nodely.engine.applicative/eval-key-contextual env k (assoc opts ::applicative/context applicative.core-async/context))))) diff --git a/src/nodely/engine/lazy.clj b/src/nodely/engine/lazy.clj index 2489d10..61bb1bd 100644 --- a/src/nodely/engine/lazy.clj +++ b/src/nodely/engine/lazy.clj @@ -1,6 +1,7 @@ (ns nodely.engine.lazy (:refer-clojure :exclude [eval resolve]) (:require + [clojure.core.async :as async] [nodely.data :as data] [nodely.engine.core :as core])) @@ -12,6 +13,10 @@ [env k] (data/get-value (eval env k) k)) +(defn eval-key-channel + [env k] + (async/thread (eval-key env k))) + (defn eval-node [node env] (eval-key (assoc env ::target node) ::target)) diff --git a/test/nodely/api_test.clj b/test/nodely/api_test.clj index d394a92..251f6b5 100644 --- a/test/nodely/api_test.clj +++ b/test/nodely/api_test.clj @@ -1,7 +1,21 @@ (ns nodely.api-test (:refer-clojure :exclude [cond]) (:require - [clojure.test :refer :all])) + [clojure.core.async :as async] + [clojure.test :refer :all] + [nodely.api.v0 :as api :refer [>value >leaf eval-key-channel]])) + +(def env {:x (>value 2) + :y (>value 3) + :z (>leaf (+ ?x ?y))}) + +(deftest eval-key-channel-test + (testing "returning a result to a channel with :sync.lazy" + (is (= 5 (async/