mirror of
https://github.com/penpot/penpot.git
synced 2025-08-03 01:38:27 +02:00
♻️ Make the worker abstraction more scalable
Start using redis for dispatcher to worker communication and add the ability to start multiple threads to worker for increase the concurrency.
This commit is contained in:
parent
13a092b192
commit
0600b2abe4
16 changed files with 827 additions and 625 deletions
|
@ -23,7 +23,7 @@
|
|||
com.cognitect/transit-cljs {:mvn/version "0.8.280"}
|
||||
java-http-clj/java-http-clj {:mvn/version "0.4.3"}
|
||||
|
||||
funcool/promesa {:mvn/version "9.1.540"}
|
||||
funcool/promesa {:mvn/version "9.2.541"}
|
||||
funcool/cuerdas {:mvn/version "2022.06.16-403"}
|
||||
|
||||
lambdaisland/uri {:mvn/version "1.13.95"
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.common.data
|
||||
"Data manipulation and query helper functions."
|
||||
"A collection if helpers for working with data structures and other
|
||||
data resources."
|
||||
(:refer-clojure :exclude [read-string hash-map merge name update-vals
|
||||
parse-double group-by iteration concat mapcat])
|
||||
#?(:cljs
|
||||
|
@ -22,7 +23,9 @@
|
|||
[linked.set :as lks])
|
||||
|
||||
#?(:clj
|
||||
(:import linked.set.LinkedSet)))
|
||||
(:import
|
||||
linked.set.LinkedSet
|
||||
java.lang.AutoCloseable)))
|
||||
|
||||
(def boolean-or-nil?
|
||||
(some-fn nil? boolean?))
|
||||
|
@ -697,3 +700,16 @@
|
|||
(map (fn [key]
|
||||
[key (delay (generator-fn key))]))
|
||||
keys))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Util protocols
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defprotocol ICloseable
|
||||
:extend-via-metadata true
|
||||
(close! [_] "Close the resource."))
|
||||
|
||||
#?(:clj
|
||||
(extend-protocol ICloseable
|
||||
AutoCloseable
|
||||
(close! [this] (.close this))))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#_:clj-kondo/ignore
|
||||
(ns app.common.data.macros
|
||||
"Data retrieval & manipulation specific macros."
|
||||
(:refer-clojure :exclude [get-in select-keys str])
|
||||
(:refer-clojure :exclude [get-in select-keys str with-open])
|
||||
#?(:cljs (:require-macros [app.common.data.macros]))
|
||||
(:require
|
||||
#?(:clj [clojure.core :as c]
|
||||
|
@ -94,5 +94,16 @@
|
|||
[s & params]
|
||||
`(str/ffmt ~s ~@params))
|
||||
|
||||
|
||||
|
||||
(defmacro with-open
|
||||
[bindings & body]
|
||||
{:pre [(vector? bindings)
|
||||
(even? (count bindings))
|
||||
(pos? (count bindings))]}
|
||||
(reduce (fn [acc bindings]
|
||||
`(let ~(vec bindings)
|
||||
(try
|
||||
~acc
|
||||
(finally
|
||||
(d/close! ~(first bindings))))))
|
||||
`(do ~@body)
|
||||
(reverse (partition 2 bindings))))
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
[& exprs]
|
||||
`(try* (^:once fn* [] ~@exprs) identity))
|
||||
|
||||
(defmacro try!
|
||||
[& exprs]
|
||||
`(try* (^:once fn* [] ~@exprs) identity))
|
||||
|
||||
(defn with-always
|
||||
"A helper that evaluates an exptession independently if the body
|
||||
raises exception or not."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue