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