Add KRAKEN_ENABLED flag to disable Kraken pollers in local dev

Same pattern as BINANCE_ENABLED and STRIKE_ENABLED. Prevents local
dev from fetching external pricing data when pointed at btcprod.
Docker explicitly sets KRAKEN_ENABLED=true.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 10:45:10 +01:00
co-authored by Claude Opus 4.6
parent 8b5c1faeaa
commit 747c834e6a
4 changed files with 37 additions and 28 deletions
+1
View File
@@ -19,6 +19,7 @@ services:
CORS_ORIGIN: "${DOCKER_CORS_ORIGIN}" CORS_ORIGIN: "${DOCKER_CORS_ORIGIN}"
FRANKFURTER_URL: "${DOCKER_FRANKFURTER_URL}" FRANKFURTER_URL: "${DOCKER_FRANKFURTER_URL}"
STRIKE_API_KEY: "${STRIKE_API_KEY}" STRIKE_API_KEY: "${STRIKE_API_KEY}"
KRAKEN_ENABLED: "true"
extra_hosts: extra_hosts:
- "postgres:host-gateway" - "postgres:host-gateway"
+4 -2
View File
@@ -56,10 +56,12 @@
:enabled? #or [#env BINANCE_ENABLED "true"]} :enabled? #or [#env BINANCE_ENABLED "true"]}
:kraken/ohlc :kraken/ohlc
{:query-fn #ig/ref :db.sql/query-fn} {:query-fn #ig/ref :db.sql/query-fn
:enabled? #or [#env KRAKEN_ENABLED "true"]}
:kraken/ohlc-day :kraken/ohlc-day
{:query-fn #ig/ref :db.sql/query-fn} {:query-fn #ig/ref :db.sql/query-fn
:enabled? #or [#env KRAKEN_ENABLED "true"]}
:frankfurter/rates :frankfurter/rates
{:url #or [#env FRANKFURTER_URL "http://localhost:8080"] {:url #or [#env FRANKFURTER_URL "http://localhost:8080"]
+16 -13
View File
@@ -103,19 +103,22 @@
(log/error e "Kraken OHLC poll failed")))))))) (log/error e "Kraken OHLC poll failed"))))))))
(defmethod ig/init-key :kraken/ohlc (defmethod ig/init-key :kraken/ohlc
[_ {:keys [query-fn]}] [_ {:keys [query-fn enabled?]}]
(let [client (HttpClient/newHttpClient) (if (= enabled? "false")
db-since (seed-since-from-db query-fn) (do (log/info "Kraken OHLC poller disabled")
since (atom db-since) {:running? (atom false)})
running? (atom true) (let [client (HttpClient/newHttpClient)
has-data? (some? db-since) db-since (seed-since-from-db query-fn)
fut (start-poll-loop! client query-fn since running? has-data?)] since (atom db-since)
(if has-data? running? (atom true)
(log/info "Starting Kraken OHLC poller, next fetch in" (quot (ms-until-next-poll) 60000) "minutes") has-data? (some? db-since)
(log/info "Starting Kraken OHLC poller, fetching immediately (no data)")) fut (start-poll-loop! client query-fn since running? has-data?)]
{:running? running? (if has-data?
:future fut (log/info "Starting Kraken OHLC poller, next fetch in" (quot (ms-until-next-poll) 60000) "minutes")
:since since})) (log/info "Starting Kraken OHLC poller, fetching immediately (no data)"))
{:running? running?
:future fut
:since since})))
(defmethod ig/halt-key! :kraken/ohlc (defmethod ig/halt-key! :kraken/ohlc
[_ {:keys [running? future]}] [_ {:keys [running? future]}]
+16 -13
View File
@@ -102,19 +102,22 @@
(log/error e "Kraken daily OHLC poll failed")))))))) (log/error e "Kraken daily OHLC poll failed"))))))))
(defmethod ig/init-key :kraken/ohlc-day (defmethod ig/init-key :kraken/ohlc-day
[_ {:keys [query-fn]}] [_ {:keys [query-fn enabled?]}]
(let [client (HttpClient/newHttpClient) (if (= enabled? "false")
db-since (seed-since-from-db query-fn) (do (log/info "Kraken daily OHLC poller disabled")
since (atom db-since) {:running? (atom false)})
running? (atom true) (let [client (HttpClient/newHttpClient)
has-data? (some? db-since) db-since (seed-since-from-db query-fn)
fut (start-poll-loop! client query-fn since running? has-data?)] since (atom db-since)
(if has-data? running? (atom true)
(log/info "Starting Kraken daily OHLC poller, next fetch in" (quot (ms-until-next-daily-poll) 60000) "minutes") has-data? (some? db-since)
(log/info "Starting Kraken daily OHLC poller, fetching immediately (no data)")) fut (start-poll-loop! client query-fn since running? has-data?)]
{:running? running? (if has-data?
:future fut (log/info "Starting Kraken daily OHLC poller, next fetch in" (quot (ms-until-next-daily-poll) 60000) "minutes")
:since since})) (log/info "Starting Kraken daily OHLC poller, fetching immediately (no data)"))
{:running? running?
:future fut
:since since})))
(defmethod ig/halt-key! :kraken/ohlc-day (defmethod ig/halt-key! :kraken/ohlc-day
[_ {:keys [running? future]}] [_ {:keys [running? future]}]