mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 16:41:38 +02:00
🚧 Major refactor of backend code.
Relevant changes: - ring -> vertx - suricatta -> vertx-pgsql - emails improvements - logging - hybrid sync/async -> full async execution model - database layout refactor
This commit is contained in:
parent
73753ce071
commit
e9b00339a5
134 changed files with 5394 additions and 6598 deletions
|
@ -203,3 +203,15 @@
|
|||
;; (let [keys# (map #(keyword (name %)) fields)
|
||||
;; vals# fields]
|
||||
;; (apply hash-map (interleave keys# vals#))))
|
||||
|
||||
;; (defmacro some->'
|
||||
;; [x & forms]
|
||||
;; `(let [x# (p/then' ~x (fn [v#]
|
||||
;; (when (nil? v#)
|
||||
;; (throw (ex-info "internal" {::some-interrupt true})))
|
||||
;; v#))]
|
||||
;; (-> (-> x# ~@forms)
|
||||
;; (p/catch' (fn [e#]
|
||||
;; (if (::some-interrupt (ex-data e#))
|
||||
;; nil
|
||||
;; (throw e#)))))))
|
||||
|
|
|
@ -40,7 +40,9 @@
|
|||
ErrorCode.TIMEOUT :timeout
|
||||
ErrorCode.EXCEPTION :exception
|
||||
ErrorCode.HTTP_ERROR :http
|
||||
ErrorCode.ABORT :abort))
|
||||
ErrorCode.ABORT :abort
|
||||
ErrorCode.OFFLINE :offline
|
||||
nil))
|
||||
|
||||
(defn- translate-response-type
|
||||
[type]
|
||||
|
@ -72,18 +74,18 @@
|
|||
(rx/create
|
||||
(fn [sink]
|
||||
(letfn [(on-complete [event]
|
||||
(if (or (= (.getLastErrorCode xhr) ErrorCode.HTTP_ERROR)
|
||||
(.isSuccess xhr))
|
||||
(sink (rx/end
|
||||
{:status (.getStatus xhr)
|
||||
:body (.getResponse xhr)
|
||||
:headers (normalize-headers
|
||||
(.getResponseHeaders xhr))}))
|
||||
(sink (let [type (-> (.getLastErrorCode xhr)
|
||||
(translate-error-code))
|
||||
message (.getLastError xhr)]
|
||||
(ex-info message {:type type})))))]
|
||||
|
||||
(let [type (translate-error-code (.getLastErrorCode xhr))
|
||||
status (.getStatus xhr)]
|
||||
;; (prn "on-complete" type method url)
|
||||
(if (pos? status)
|
||||
(sink (rx/end
|
||||
{:status status
|
||||
:body (.getResponse xhr)
|
||||
:headers (normalize-headers (.getResponseHeaders xhr))}))
|
||||
(sink (rx/end
|
||||
{:status 0
|
||||
:error (if (= type :http) :abort type)
|
||||
::xhr xhr})))))]
|
||||
(events/listen xhr EventType.COMPLETE on-complete)
|
||||
(.send xhr uri method body headers)
|
||||
#(.abort xhr))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue