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 6, 2024
1 parent 3865c51 commit 9f0215b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/nl/surf/eduhub_rio_mapper/cli_commands.clj
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,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))))))
18 changes: 11 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 @@ -159,12 +162,13 @@
(assoc :clients (clients-info/read-clients-data clients-info-config)))))))

(defn make-config-and-handlers []
(println "make-config-and-handlers")
(let [{:keys [clients] :as cfg} (make-config)
handlers (processing/make-handlers cfg)
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 9f0215b

Please sign in to comment.