mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 16:41:39 +02:00
♻️ Refactor exporter
- Migrate from puppeteer to playwright - Fix many lifecycle and resource usage issues - Add redis integration - Enable multiple exportation - Enable asynchronos exportation (with progress reporting)
This commit is contained in:
parent
f0a9889f33
commit
4a9e38a221
21 changed files with 1366 additions and 1017 deletions
54
exporter/src/app/redis.cljs
Normal file
54
exporter/src/app/redis.cljs
Normal file
|
@ -0,0 +1,54 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) UXBOX Labs SL
|
||||
|
||||
(ns app.redis
|
||||
(:require
|
||||
["ioredis" :as redis]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.logging :as l]
|
||||
[app.common.transit :as t]
|
||||
[app.config :as cf]))
|
||||
|
||||
(l/set-level! :trace)
|
||||
|
||||
(def client (atom nil))
|
||||
|
||||
(defn- create-client
|
||||
[uri]
|
||||
(let [^js client (new redis uri)]
|
||||
(.on client "connect"
|
||||
(fn [] (l/info :hint "redis connection established" :uri uri)))
|
||||
(.on client "error"
|
||||
(fn [cause] (l/error :hint "error on redis connection" :cause cause)))
|
||||
(.on client "close"
|
||||
(fn [] (l/warn :hint "connection closed")))
|
||||
(.on client "reconnect"
|
||||
(fn [ms] (l/warn :hint "reconnecting to redis" :ms ms)))
|
||||
(.on client "end"
|
||||
(fn [ms] (l/warn :hint "client ended, no more connections will be attempted")))
|
||||
client))
|
||||
|
||||
(defn init
|
||||
[]
|
||||
(swap! client (fn [prev]
|
||||
(when prev (.disconnect ^js prev))
|
||||
(create-client (cf/get :redis-uri)))))
|
||||
|
||||
|
||||
(defn stop
|
||||
[]
|
||||
(swap! client (fn [client]
|
||||
(when client (.quit ^js client))
|
||||
nil)))
|
||||
|
||||
(def ^:private tenant (cf/get :tenant))
|
||||
|
||||
(defn pub!
|
||||
[topic payload]
|
||||
(let [payload (if (map? payload) (t/encode-str payload) payload)
|
||||
topic (dm/str tenant "." topic)]
|
||||
(when-let [client @client]
|
||||
(.publish ^js client topic payload))))
|
Loading…
Add table
Add a link
Reference in a new issue