0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

Fix issues from previous refactor peer review

This commit is contained in:
Andrey Antukh 2022-03-09 17:29:33 +01:00
parent 9841a39d04
commit f7bb08382c
6 changed files with 23 additions and 33 deletions

View file

@ -141,8 +141,7 @@
(s/def ::host ::us/string)
(s/def ::http-server-port ::us/integer)
(s/def ::http-server-host ::us/string)
(s/def ::http-server-min-threads ::us/integer)
(s/def ::http-server-max-threads ::us/integer)
(s/def ::http-server-io-threads ::us/integer)
(s/def ::http-session-idle-max-age ::dt/duration)
(s/def ::http-session-updater-batch-max-age ::dt/duration)
(s/def ::http-session-updater-batch-max-size ::us/integer)
@ -243,8 +242,7 @@
::host
::http-server-host
::http-server-port
::http-server-max-threads
::http-server-min-threads
::http-server-io-threads
::http-session-idle-max-age
::http-session-updater-batch-max-age
::http-session-updater-batch-max-size

View file

@ -10,6 +10,7 @@
[app.common.exceptions :as ex]
[app.common.logging :as l]
[app.common.spec :as us]
[app.config :as cf]
[app.http.doc :as doc]
[app.http.errors :as errors]
[app.http.middleware :as middleware]
@ -35,9 +36,7 @@
(s/def ::host ::us/string)
(s/def ::name ::us/string)
(s/def ::executors (s/map-of keyword? ::wrk/executor))
;; (s/def ::max-threads ::cf/http-server-max-threads)
;; (s/def ::min-threads ::cf/http-server-min-threads)
(s/def ::io-threads ::cf/http-server-io-threads)
(defmethod ig/prep-key ::server
[_ cfg]
@ -48,7 +47,7 @@
(defmethod ig/pre-init-spec ::server [_]
(s/keys :req-un [::port ::host ::name ::executors]
:opt-un [::router ::handler]))
:opt-un [::router ::handler ::io-threads]))
(defmethod ig/init-key ::server
[_ {:keys [handler router port name host executors] :as cfg}]
@ -97,7 +96,7 @@
(handler request respond
(fn [cause]
(l/error :hint "unexpected error processing request"
::l/context (errors/get-error-context request cause)
::l/context (errors/get-context request)
:query-string (yrq/query request)
:cause cause)
(respond (yrs/response 500 "internal server error")))))))

View file

@ -21,18 +21,17 @@
(yrq/get-header request "x-real-ip")
(yrq/remote-addr request)))
(defn get-error-context
[request error]
(let [data (ex-data error)]
(merge
{:path (:uri request)
:method (:request-method request)
:params (:params request)
:ip-addr (parse-client-ip request)
:profile-id (:profile-id request)}
(let [headers (:headers request)]
{:user-agent (get headers "user-agent")
:frontend-version (get headers "x-frontend-version" "unknown")}))))
(defn get-context
[request]
(merge
{:path (:uri request)
:method (:request-method request)
:params (:params request)
:ip-addr (parse-client-ip request)
:profile-id (:profile-id request)}
(let [headers (:headers request)]
{:user-agent (get headers "user-agent")
:frontend-version (get headers "x-frontend-version" "unknown")})))
(defmulti handle-exception
(fn [err & _rest]
@ -61,7 +60,7 @@
(let [edata (ex-data error)
explain (us/pretty-explain edata)]
(l/error ::l/raw (ex-message error)
::l/context (get-error-context request error)
::l/context (get-context request)
:cause error)
(yrs/response :status 500
:body {:type :server-error
@ -87,7 +86,7 @@
(handle-exception (:handling edata) request)
(do
(l/error ::l/raw (ex-message error)
::l/context (get-error-context request error)
::l/context (get-context request)
:cause error)
(yrs/response 500 {:type :server-error
:code :unexpected
@ -98,7 +97,7 @@
[error request]
(let [state (.getSQLState ^java.sql.SQLException error)]
(l/error ::l/raw (ex-message error)
::l/context (get-error-context request error)
::l/context (get-context request)
:cause error)
(cond
(= state "57014")

View file

@ -113,7 +113,8 @@
:host (cf/get :http-server-host)
:router (ig/ref :app.http/router)
:metrics (ig/ref :app.metrics/metrics)
:executors (ig/ref :app.worker/executors)}
:executors (ig/ref :app.worker/executors)
:io-threads (cf/get :http-server-io-threads)}
:app.http/router
{:assets (ig/ref :app.http.assets/handlers)

View file

@ -262,10 +262,3 @@
:gauge (make-gauge props)
:summary (make-summary props)
:histogram (make-histogram props)))
;; (defn instrument-jetty!
;; [^CollectorRegistry registry ^StatisticsHandler handler]
;; (doto (JettyStatisticsCollector. handler)
;; (.register registry))
;; nil)

View file

@ -259,7 +259,7 @@
;; A task responsible to permanently delete already marked as deleted
;; storage files. The storage objects are practically never marked to
;; be deleted directly by the api call. The touched-gc is responsible
;; collect the usage of the object and mark it as deleted.
;; of collecting the usage of the object and mark it as deleted.
(declare sql:retrieve-deleted-objects-chunk)