Set up some debugging features for square jobs.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
(mu/with-context {:background-job name
|
||||
:service name}
|
||||
(mount/start (mount/only #{#'conn #'metrics-setup #'container-tags #'logging-context #'container-data }))
|
||||
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler))
|
||||
((heartbeat f name))
|
||||
(log/info "Stopping " name)
|
||||
(Thread/sleep 15000)
|
||||
|
||||
@@ -25,12 +25,6 @@
|
||||
"Content-Type" "application/json"})
|
||||
|
||||
|
||||
(defn retry-4 [ex try-count _]
|
||||
(log/error ::aborting-request
|
||||
:attempt try-count
|
||||
:exception ex)
|
||||
(if (> try-count 4) false true))
|
||||
|
||||
(def manifold-api-stream
|
||||
(let [stream (s/stream 100)]
|
||||
(->> stream
|
||||
@@ -47,17 +41,17 @@
|
||||
:background-job "Square 3")
|
||||
(try
|
||||
(client/request (assoc request
|
||||
:socket-timeout 10000
|
||||
:connection-timeout 10000
|
||||
:as :json
|
||||
:retry-handler retry-4))
|
||||
(catch Exception e
|
||||
(log/error ::raw-request-failed
|
||||
:socket-timeout 5000
|
||||
:connection-timeout 5000
|
||||
:connection-request-timeout 5000
|
||||
:as :json))
|
||||
(catch Throwable e
|
||||
(log/warn ::raw-request-failed
|
||||
:exception e)
|
||||
(throw e)))))
|
||||
(de/catch
|
||||
(fn [e]
|
||||
(if (= attempt 5)
|
||||
(if (>= attempt 5)
|
||||
(throw e)
|
||||
(de/chain
|
||||
(mt/in 1000 (fn [] 1))
|
||||
@@ -144,7 +138,7 @@
|
||||
(mu/with-context lc
|
||||
(item->category-name-impl client item))))
|
||||
(fn [e]
|
||||
(log/error ::couldnt-fetch-variation
|
||||
(log/warn ::couldnt-fetch-variation
|
||||
:exception e)
|
||||
"Uncategorized"))
|
||||
|
||||
@@ -153,7 +147,7 @@
|
||||
:category_data
|
||||
:name)
|
||||
(fn [e]
|
||||
(log/error ::couldnt-fetch-category
|
||||
(log/warn ::couldnt-fetch-category
|
||||
:exception e)
|
||||
"Uncategorized"))
|
||||
|
||||
@@ -324,6 +318,7 @@
|
||||
(de/success-deferred
|
||||
(->> (:tenders order)
|
||||
(map #(tender->charge order client location %))))
|
||||
(de/catch
|
||||
(de/let-flow [line-items
|
||||
(->>
|
||||
(or (:line_items order) [])
|
||||
@@ -369,7 +364,10 @@
|
||||
(-> order :return_amounts :discount_money amount->money))
|
||||
:charges (->> (:tenders order)
|
||||
(map #(tender->charge order client location %)))
|
||||
:line-items line-items})])))))
|
||||
:line-items line-items})])
|
||||
(fn [e]
|
||||
(log/error ::failed-to-transform-order
|
||||
:exception e)))))))
|
||||
|
||||
(defn daily-results
|
||||
([client location]
|
||||
@@ -498,7 +496,7 @@
|
||||
(map (fn [p] {:charge/external-id (str "square/charge/" (:payment_id p))})))})
|
||||
(filter :expected-deposit/date)
|
||||
(into []))
|
||||
(catch Exception e
|
||||
(catch Throwable e
|
||||
(log/error ::transform-settlement-failed
|
||||
:exception e)))))))
|
||||
|
||||
@@ -694,7 +692,7 @@
|
||||
(mu/with-context lc
|
||||
(let [data (ex-data e)]
|
||||
(log/info ::upsert-all-failed
|
||||
:severity :warn
|
||||
:severity :error
|
||||
:exception e)
|
||||
(cond (= (:status data) 401)
|
||||
(mark-integration-status client {:integration-status/state :integration-state/unauthorized
|
||||
|
||||
Reference in New Issue
Block a user