|
|
@@ -5,7 +5,7 @@
|
|
|
[clojure.set :as set]
|
|
|
[datascript.core :as d]
|
|
|
[frontend.common.missionary-util :as c.m]
|
|
|
- [frontend.worker.rtc.log :as rtc-log]
|
|
|
+ [frontend.worker.rtc.log-and-state :as rtc-log-and-state]
|
|
|
[frontend.worker.rtc.op-mem-layer :as op-mem-layer]
|
|
|
[frontend.worker.rtc.ws-util :as ws-util]
|
|
|
[frontend.worker.state :as worker-state]
|
|
|
@@ -110,7 +110,7 @@
|
|
|
(defn new-task--upload-graph
|
|
|
[get-ws-create-task repo conn remote-graph-name]
|
|
|
(m/sp
|
|
|
- (rtc-log/rtc-log :rtc.log/upload {:sub-type :fetch-presigned-put-url
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/upload {:sub-type :fetch-presigned-put-url
|
|
|
:message "fetching presigned put-url"})
|
|
|
(let [[{:keys [url key]} all-blocks-str]
|
|
|
(m/?
|
|
|
@@ -120,10 +120,10 @@
|
|
|
(m/sp
|
|
|
(let [all-blocks (export-as-blocks @conn)]
|
|
|
(ldb/write-transit-str all-blocks)))))]
|
|
|
- (rtc-log/rtc-log :rtc.log/upload {:sub-type :upload-data
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/upload {:sub-type :upload-data
|
|
|
:message "uploading data"})
|
|
|
(m/? (c.m/<! (http/put url {:body all-blocks-str :with-credentials? false})))
|
|
|
- (rtc-log/rtc-log :rtc.log/upload {:sub-type :request-upload-graph
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/upload {:sub-type :request-upload-graph
|
|
|
:message "requesting upload-graph"})
|
|
|
(let [upload-resp
|
|
|
(m/? (ws-util/send&recv get-ws-create-task {:action "upload-graph"
|
|
|
@@ -138,7 +138,7 @@
|
|
|
(op-mem-layer/init-empty-ops-store! repo)
|
|
|
(op-mem-layer/update-graph-uuid! repo graph-uuid)
|
|
|
(m/? (op-mem-layer/new-task--sync-to-idb repo))
|
|
|
- (rtc-log/rtc-log :rtc.log/upload {:sub-type :upload-completed
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/upload {:sub-type :upload-completed
|
|
|
:message "upload-graph completed"})
|
|
|
nil)
|
|
|
(throw (ex-info "upload-graph failed" {:upload-resp upload-resp})))))))
|
|
|
@@ -245,18 +245,20 @@
|
|
|
^js worker-obj (:worker/object @worker-state/*state)]
|
|
|
(m/sp
|
|
|
(op-mem-layer/update-local-tx! repo t)
|
|
|
+ (rtc-log-and-state/update-local-t graph-uuid t)
|
|
|
+ (rtc-log-and-state/update-remote-t graph-uuid t)
|
|
|
(m/?
|
|
|
(c.m/await-promise
|
|
|
(p/do!
|
|
|
- (.createOrOpenDB worker-obj repo (ldb/write-transit-str {:close-other-db? false}))
|
|
|
- (.exportDB worker-obj repo)
|
|
|
- (.transact worker-obj repo init-tx-data {:rtc-download-graph? true
|
|
|
- :gen-undo-ops? false
|
|
|
- :persist-op? false} (worker-state/get-context))
|
|
|
- (.transact worker-obj repo tx-data {:rtc-download-graph? true
|
|
|
- :gen-undo-ops? false
|
|
|
- :persist-op? false} (worker-state/get-context))
|
|
|
- (transact-block-refs! repo))))
|
|
|
+ (.createOrOpenDB worker-obj repo (ldb/write-transit-str {:close-other-db? false}))
|
|
|
+ (.exportDB worker-obj repo)
|
|
|
+ (.transact worker-obj repo init-tx-data {:rtc-download-graph? true
|
|
|
+ :gen-undo-ops? false
|
|
|
+ :persist-op? false} (worker-state/get-context))
|
|
|
+ (.transact worker-obj repo tx-data {:rtc-download-graph? true
|
|
|
+ :gen-undo-ops? false
|
|
|
+ :persist-op? false} (worker-state/get-context))
|
|
|
+ (transact-block-refs! repo))))
|
|
|
(worker-util/post-message :add-repo {:repo repo}))))
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
@@ -265,7 +267,7 @@
|
|
|
|
|
|
(defn new-task--request-download-graph
|
|
|
[get-ws-create-task graph-uuid]
|
|
|
- (rtc-log/rtc-log :rtc.log/download {:sub-type :request-download-graph
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/download {:sub-type :request-download-graph
|
|
|
:message "requesting download graph"
|
|
|
:graph-uuid graph-uuid})
|
|
|
(m/join :download-info-uuid
|
|
|
@@ -282,7 +284,7 @@
|
|
|
[get-ws-create-task download-info-uuid graph-uuid timeout-ms]
|
|
|
(->
|
|
|
(m/sp
|
|
|
- (rtc-log/rtc-log :rtc.log/download {:sub-type :wait-remote-graph-data-ready
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/download {:sub-type :wait-remote-graph-data-ready
|
|
|
:message "waiting for the remote to prepare the data"
|
|
|
:graph-uuid graph-uuid})
|
|
|
(loop []
|
|
|
@@ -304,7 +306,7 @@
|
|
|
(defn new-task--download-graph-from-s3
|
|
|
[graph-uuid graph-name s3-url]
|
|
|
(m/sp
|
|
|
- (rtc-log/rtc-log :rtc.log/download {:sub-type :downloading-graph-data
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/download {:sub-type :downloading-graph-data
|
|
|
:message "downloading graph data"
|
|
|
:graph-uuid graph-uuid})
|
|
|
(let [^js worker-obj (:worker/object @worker-state/*state)
|
|
|
@@ -313,7 +315,7 @@
|
|
|
(if (not= 200 status)
|
|
|
(throw (ex-info "download-graph from s3 failed" {:resp r}))
|
|
|
(do
|
|
|
- (rtc-log/rtc-log :rtc.log/download {:sub-type :transact-graph-data-to-db
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/download {:sub-type :transact-graph-data-to-db
|
|
|
:message "transacting graph data to local db"
|
|
|
:graph-uuid graph-uuid})
|
|
|
(let [all-blocks (ldb/read-transit-str body)]
|
|
|
@@ -324,7 +326,7 @@
|
|
|
(m/? (op-mem-layer/new-task--sync-to-idb repo))
|
|
|
(m/? (c.m/await-promise (.storeMetadata worker-obj repo (pr-str {:kv/value graph-uuid}))))
|
|
|
(worker-state/set-rtc-downloading-graph! false)
|
|
|
- (rtc-log/rtc-log :rtc.log/download {:sub-type :download-completed
|
|
|
+ (rtc-log-and-state/rtc-log :rtc.log/download {:sub-type :download-completed
|
|
|
:message "download completed"
|
|
|
:graph-uuid graph-uuid})
|
|
|
nil))))))
|