chore: refmt due to cljfmt.edn added

This commit is contained in:
rcmerci
2024-11-27 19:15:12 +08:00
parent 0c58bb58b4
commit 5e68c3efb0
4 changed files with 108 additions and 110 deletions

View File

@@ -24,16 +24,16 @@
[ws message]
{:pre [(= "apply-ops" (:action message))]}
(m/sp
(let [decoded-message (rtc-const/data-to-ws-coercer (assoc message :req-id "temp-id"))
message-str (js/JSON.stringify (clj->js (select-keys (rtc-const/data-to-ws-encoder decoded-message)
["graph-uuid" "ops" "t-before"])))
len (.-length (utf8/encode message-str))]
(when (< 100000 len)
(let [{:keys [url key]} (m/? (ws/send&recv ws {:action "presign-put-temp-s3-obj"}))
{:keys [status] :as resp} (m/? (http/put url {:body message-str :with-credentials? false}))]
(when-not (http/unexceptional-status? status)
(throw (ex-info "failed to upload apply-ops message" {:resp resp})))
key)))))
(let [decoded-message (rtc-const/data-to-ws-coercer (assoc message :req-id "temp-id"))
message-str (js/JSON.stringify (clj->js (select-keys (rtc-const/data-to-ws-encoder decoded-message)
["graph-uuid" "ops" "t-before"])))
len (.-length (utf8/encode message-str))]
(when (< 100000 len)
(let [{:keys [url key]} (m/? (ws/send&recv ws {:action "presign-put-temp-s3-obj"}))
{:keys [status] :as resp} (m/? (http/put url {:body message-str :with-credentials? false}))]
(when-not (http/unexceptional-status? status)
(throw (ex-info "failed to upload apply-ops message" {:resp resp})))
key)))))
(defn send&recv
"Return a task: throw exception if recv ex-data response.
@@ -44,18 +44,18 @@
- adjust its timeout to 20s"
[get-ws-create-task message]
(m/sp
(let [ws (m/? get-ws-create-task)
opts (when (and (= "apply-ops" (:action message))
(< 400 (count (:ops message))))
{:timeout-ms 20000})
s3-key (when (= "apply-ops" (:action message))
(m/? (put-apply-ops-message-on-s3-if-too-huge ws message)))
message* (if s3-key
(-> message
(assoc :s3-key s3-key)
(dissoc :graph-uuid :ops :t-before))
message)]
(handle-remote-ex (m/? (ws/send&recv ws message* opts))))))
(let [ws (m/? get-ws-create-task)
opts (when (and (= "apply-ops" (:action message))
(< 400 (count (:ops message))))
{:timeout-ms 20000})
s3-key (when (= "apply-ops" (:action message))
(m/? (put-apply-ops-message-on-s3-if-too-huge ws message)))
message* (if s3-key
(-> message
(assoc :s3-key s3-key)
(dissoc :graph-uuid :ops :t-before))
message)]
(handle-remote-ex (m/? (ws/send&recv ws message* opts))))))
(defn get-ws-url
[token]
@@ -72,13 +72,13 @@
{:*current-ws *current-ws
:get-ws-create-task
(m/sp
(let [ws @*current-ws]
(if (and ws
(not (ws/closed? ws)))
ws
(let [ws (m/? ws-create-task)]
(reset! *current-ws ws)
ws))))}))
(let [ws @*current-ws]
(if (and ws
(not (ws/closed? ws)))
ws
(let [ws (m/? ws-create-task)]
(reset! *current-ws ws)
ws))))}))
(def gen-get-ws-create-map--memoized
"Return a memoized task to reuse the same websocket."