Skip to content

Commit

Permalink
STORE_HTTP_REQUESTS should use opts-specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdemare committed Dec 10, 2024
1 parent 068b2cc commit f8039ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/nl/surf/eduhub_rio_mapper/cli_commands.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
(:require [clojure.data.json :as json]
[clojure.java.io :as io]
[clojure.string :as str]
[nl.jomco.envopts :as envopts]
[nl.surf.eduhub-rio-mapper.clients-info :as clients-info]
[nl.surf.eduhub-rio-mapper.config :as config]
[nl.surf.eduhub-rio-mapper.endpoints.api :as api]
Expand Down Expand Up @@ -121,10 +122,7 @@
(resolver type id (:institution-oin client-info)))

"document-env-vars"
(let [x (map (fn [[k v]] [(-> k name str/upper-case (str/replace #"-" "_")) (first v)]) config/opts-spec)
max-env-length (last (sort (map #(count (first %)) x)))
output (map (fn [[env desc]] (str env " " (apply str (repeat (- max-env-length (count env) -1) " ")) desc)) x)]
(str/join "\n" (sort output)))
(envopts/specs-description config/opts-spec)

("upsert" "delete" "delete-by-code")
(let [[client-info [type id rest-args]] (parse-client-info-args args clients)
Expand All @@ -139,4 +137,4 @@
name-id id})
{:action command
::ooapi/id id}))]
(job/run! handlers job (= (System/getenv "STORE_HTTP_REQUESTS") "true")))))
(job/run! handlers job (= "true" (:store-http-requests config))))))
17 changes: 10 additions & 7 deletions src/nl/surf/eduhub_rio_mapper/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@
:api-hostname ["Hostname for listing web API" :str
:default "localhost"
:in [:api-config :host]]
:worker-api-port ["HTTP port for serving web API" :int
:worker-api-port ["HTTP port for serving worker web API" :int
:default 8080
:in [:worker-api-config :port]]
:worker-api-hostname ["Hostname for listing web API" :str
:worker-api-hostname ["Hostname for listing worker web API" :str
:default "localhost"
:in [:worker-api-config :host]]
:job-retry-wait-ms ["Number of ms to wait before retrying job" :int
:job-retry-wait-ms ["Number of milliseconds to wait before retrying a failed job" :int
:default 5000
:in [:worker :retry-wait-ms]]
:job-max-retries ["Max number of retries of a job" :int
:job-max-retries ["Max number of retries of a failed job" :int
:default 3
:in [:worker :max-retries]]
:redis-uri ["URI to redis" :str
Expand All @@ -88,9 +88,12 @@
:default [5,30,120,600]
:parser parse-int-list
:in [:rio-config :rio-retry-attempts-seconds]]
:status-ttl-sec ["Number of seconds hours to keep job status" :int
:status-ttl-sec ["Number of seconds to keep job status" :int
:default (* 60 60 24 7) ;; one week
:in [:status-ttl-sec]]})
:in [:status-ttl-sec]]
:store-http-requests ["Boolean; should all http traffic be logged? Defaults to true." :str
:default "true"
:in [:store-http-requests]]})

(defn help []
(envopts/specs-description opts-spec))
Expand Down Expand Up @@ -164,7 +167,7 @@
config (update cfg :worker merge
{:queues (clients-info/institution-schac-homes clients)
:queue-fn :institution-schac-home
:run-job-fn #(job/run! handlers % (= (System/getenv "STORE_HTTP_REQUESTS") "true"))
:run-job-fn #(job/run! handlers % (= "true" (:store-http-requests cfg)))
:set-status-fn (status/make-set-status-fn cfg)
:retryable-fn status/retryable?
:error-fn status/errors?})]
Expand Down
2 changes: 1 addition & 1 deletion src/nl/surf/eduhub_rio_mapper/endpoints/status.clj
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
;; xml response converted to edn.
(assoc :attributes {:opleidingseenheidcode opleidingseenheidcode})

(and (= (System/getenv "STORE_HTTP_REQUESTS") "true")
(and (= "true" (:store-http-requests config))
(#{:done :error :time-out} status)
(-> data :http-messages))
(assoc :http-messages (-> data :http-messages))
Expand Down

0 comments on commit f8039ff

Please sign in to comment.