diff --git a/caddy/Caddyfile b/caddy/Caddyfile index b90646d6290634ded107d70212522d735218912b..2dad1ddf0e6dd9e02b5a0d6404c29fdd871815fc 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -141,7 +141,7 @@ } @rest_apis { - path /hafah-api/* /balance-api/* /reputation-api/* /hafbe-api/* /hivesense-api/* + path /hafah-api/* /balance-api/* /reputation-api/* /hafbe-api/* /hivesense-api/* /hivemind-api/* } handle @rest_apis { diff --git a/hafah.yaml b/hafah.yaml index 1dd6347f1bc6813948b7b3bc051c56200252f56e..75fc138333bf26d45b88781ce7f3ab1cb9a8ad07 100644 --- a/hafah.yaml +++ b/hafah.yaml @@ -6,6 +6,7 @@ services: - hafah - hafbe - haf-block-explorer-drop-db + - hivemind environment: POSTGRES_URL: postgresql://haf_admin@haf/haf_block_log command: diff --git a/hivemind.yaml b/hivemind.yaml index ff2626932fadf60549cca5fcc771852ea753d11a..02b79846bcdee112855f7478246da95cb327fb04 100644 --- a/hivemind.yaml +++ b/hivemind.yaml @@ -10,9 +10,12 @@ services: - "setup" - "--database-admin-url=postgresql://haf_admin@haf/haf_block_log" - "--statement-timeout=${HIVEMIND_STATEMENT_TIMEOUT:-5000}" + - "--swagger-url=${PUBLIC_HOSTNAME}" depends_on: haf: condition: service_healthy + hafah-install: + condition: service_completed_successfully reputation-tracker-install: condition: service_completed_successfully @@ -45,8 +48,6 @@ services: depends_on: haf: condition: service_healthy - reputation-tracker-install: - condition: service_completed_successfully hivemind-install: condition: service_completed_successfully @@ -81,7 +82,7 @@ services: PGRST_DB_ANON_ROLE: hivemind_user PGRST_DB_POOL: 40 PGRST_DB_POOL_ACQUISITION_TIMEOUT: 10 - PGRST_OPENAPI_MODE: "disabled" # unclear why this is set, I guess because we currently only support json-rpc? + # PGRST_OPENAPI_MODE: "disabled" # unclear why this is set, I guess because we currently only support json-rpc? # when debugging, you can enable this # PGRST_DB_PLAN_ENABLED: true PGRST_LOG_LEVEL: ${HIVEMIND_SERVER_LOG_LEVEL:-error} diff --git a/swagger.yaml b/swagger.yaml index f520297f85ea09c81ab1045e25b7e9cb510dd5f6..85a1f48254e99b8be01e84d46a7c96d7338af22e 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -12,7 +12,8 @@ services: {url: "/balance-api/", name: "Balance Tracker"}, {url: "/reputation-api/", name: "Reputation Tracker"}, {url: "/hivesense-api/", name: "Hivesense"}, - {url: "/hafah-api/", name: "HAfAH"}] + {url: "/hafah-api/", name: "HAfAH"}, + {url: "/hivemind-api/", name: "Hivemind"}] networks: haf-network: #healthcheck: diff --git a/varnish/default.vcl b/varnish/default.vcl index fc18e0971985ec1bc1c34abd6c72033b670e57f3..7817687c7ce7483132de2f5d5e21971f6ecbb6e2 100644 --- a/varnish/default.vcl +++ b/varnish/default.vcl @@ -46,6 +46,11 @@ backend hivesense { .port = "7011"; } +backend hivemind { + .host = "haproxy"; + .port = "7002"; +} + #backend hivesense_swagger { # .host = "hivesense-swagger"; # .port = "81"; @@ -122,6 +127,17 @@ sub vcl_recv { set req.url = regsub(req.url, "^/hivesense-api/(.*)$", "/\1"); set req.backend_hint = hivesense; + if (req.method == "POST") { + call recv_cachable_post; + } + } elseif (req.url == "/hivemind-api/") { + set req.url = "/"; + set req.backend_hint = hivemind; + } elseif (req.url ~ "^/hivemind-api/") { + # rewrite the URL to where PostgREST expects it + set req.url = regsub(req.url, "^/hivemind-api/(.*)$", "/\1"); + set req.backend_hint = hivemind; + if (req.method == "POST") { call recv_cachable_post; } @@ -139,7 +155,7 @@ sub vcl_backend_fetch { } sub vcl_backend_response { - if (bereq.backend == hafah || bereq.backend == balance_tracker || bereq.backend == reputation_tracker || bereq.backend == haf_block_explorer || bereq.backend == hivemind_rtracker || bereq.backend == hivesense) { + if (bereq.backend == hafah || bereq.backend == balance_tracker || bereq.backend == reputation_tracker || bereq.backend == haf_block_explorer || bereq.backend == hivemind_rtracker || bereq.backend == hivesense || bereq.backend == hivemind) { # PostgREST generates invalid content-range headers, and varnish will refuse to cache/proxy calls because of it. # Until they fix it, just remove the header. (see https://github.com/PostgREST/postgrest/issues/1089) unset beresp.http.Content-Range; @@ -171,7 +187,9 @@ sub vcl_hash { } else if (req.backend_hint == haf_block_explorer) { hash_data("hafbe-api"); } else if (req.backend_hint == hivesense) { - hash_data("hivesense-api"); + hash_data("hivesense-api"); + } else if (req.backend_hint == hivemind) { + hash_data("hivemind-api"); } # To cache POST and PUT requests