Skip to content

Instantly share code, notes, and snippets.

;;;; Macro definition
(s/fdef defcommand
:args (s/cat :name ::command-name
:description (s/? ::command-description)
:inputs ::command-inputs
:forms (s/* ::command-form)
:implementation ::command-implementation)
:ret ::s/any)
(ns workflo.macros.command
(:require [clojure.spec :as s]
[clojure.spec.gen :as gen]))
(s/def ::command-name
symbol?)
(s/def ::command-description
string?)
{:onyx/name :redis
:onyx/plugin :onyx.plugin.redis/writer
:onyx/type :output
:onyx/medium :redis
:redis/uri "redis://localhost:6379"
:onyx/batch-size batch-size}
boot.user=> (clojure.pprint/pprint onyx.plugin.redis/operations)
{:exists #'taoensso.carmine/exists,
:role #'taoensso.carmine/role,
:ping #'taoensso.carmine/ping,
:del #'taoensso.carmine/del,
:zscan #'taoensso.carmine/zscan,
:zremrangebyrank #'taoensso.carmine/zremrangebyrank,
:lpushx #'taoensso.carmine/lpushx,
:command-info #'taoensso.carmine/command-info,
:mget #'taoensso.carmine/mget,
(do
(om.next/defui
User
static
om.next/IQuery
(query
[this]
[({:user (om.next/get-query User)} '{:id ?user-id})]))
(def user (workflo.macros.view/factory User {}))
(workflo.macros.view/register-view! 'User {:factory user, :view User}))
;;;; Test code
(require '[clojure.spec :as s])
(s/def ::simple-value
symbol?)
(s/def ::link-value
(s/tuple symbol? any?)
#_(s/tuple symbol? keyword?)
(comment
;;;; Non-recursive queries
;; Regular property
(s/conform ::query '[a])
(s/conform ::query '[a b])
(s/conform ::query '[a b c])
;; Link property
(s/conform ::query '[[a _]])
(deftest conforming-regular-properties
(are [out in] (= out (q/conform in))
'[[:property [:simple a]]]
'[a]
'[[:property [:simple a]]
[:property [:simple b]]]
'[a b]
'[[:property [:simple a]]
boot.user=> (clojure.spec/def ::foo (clojure.spec/with-gen ::bar #(clojure.spec.gen/symbol)))
:boot.user/foo
boot.user=> (clojure.spec/describe :boot.user/foo)
:clojure.spec/unknown
boot.user=> (clojure.spec/def ::bar symbol?)
:boot.user/bar
boot.user=> (clojure.spec/describe :boot.user/foo)
:clojure.spec/unknown
;;;; Deep destructuring characteristics
;; Regular properties
Query: [a b]
Result: {:a <aval> :b <bval>}
Bindings:
a -> <aval>
b -> <bval>