This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-15
Channels
- # ai (1)
- # announcements (1)
- # aws (4)
- # babashka (9)
- # biff (1)
- # calva (1)
- # clerk (15)
- # clj-kondo (24)
- # clojure (23)
- # clojure-austin (7)
- # clojure-europe (19)
- # clojure-nl (2)
- # clojure-norway (33)
- # clojurescript (43)
- # conjure (4)
- # data-science (2)
- # datahike (5)
- # datomic (14)
- # defnpodcast (27)
- # domino-clj (1)
- # events (1)
- # honeysql (13)
- # hyperfiddle (44)
- # introduce-yourself (1)
- # java (4)
- # jobs (1)
- # jobs-discuss (11)
- # lsp (3)
- # malli (14)
- # missionary (5)
- # off-topic (44)
- # pedestal (2)
- # podcasts-discuss (1)
- # releases (8)
- # remote-jobs (2)
- # shadow-cljs (3)
Hello all, if you have a nested schema, are you able to access the nested keys from the parent?
Well, let’s see:
(m/validate [:and keyword?
[:fn (fn [_] (println 1) true)]
[:fn (fn [_] (println 2) true)]
[:fn (fn [_] (println 3) true)]
[:fn (fn [_] (println 4) true)]]
:k)
;; =stout=>
;; 1
;; 2
;; 3
;; 4
;; => true
Does Parallel have more performance than serialized? Imagine the situation: You have a schema with 10 and elements Your app receives 10 requests, that your http server will process inside a thread pool of 10. Each request calls the validation. If it was parallelized, you will have 100 parallel threads at this point. It may cause performance issues in your 8 cores machine. Now imagine that inside the and, it usually fails in the 2-3 element. All left 7-8 functions will be evaluated, as they are all spawned at the same time
Maybe in your scenario it makes sense to have it parallelized, but it is not a generic "better" thing
Do benchmarks, have metrics, before move into this approach.
If that is the case, I think that a good start point is copy (defn -and-schema ...
from malli.core into your code and define your :custom.parallel/and
schema.
My problematic scenario can be "solved" by using a thread pool for validation, then you will have a constant number of threads (http thread pool size + validation thread pool size).