Quellcode durchsuchen

chore: shift app HTTP ports 8080-8083 to 8800-8803 (project rule)

Per project rule: app services use 8800-8899, canonical ports stay
as they are.

- ingestd 8080 -> 8800
- routerd 8081 -> 8801
- deliverd 8082 -> 8802
- admind 8083 -> 8803
- loadgen metrics 9091 -> 8891
- default HTTPAddr in config defaults to :8800

Updated:
- docker-compose.yml (with port convention header)
- .env.example
- deploy/prometheus/prometheus.yml
- internal/config/config.go (default)
- loadgen/cmd/http/main.go (target + metrics defaults)
- M0_VERIFICATION.md (all curl examples)
- SPEC.md (loadgen example + new port-conventions sub-section in §18)

Canonical ports left untouched: 5432 postgres, 4222/8222 nats,
6379 redis, 1883/18083 emqx, 8123/9000 clickhouse, 9090 prom,
3000 grafana.
Luis Rosales vor 2 Monaten
Ursprung
Commit
d76aa0b
7 geänderte Dateien mit 53 neuen und 34 gelöschten Zeilen
  1. 4 4
      .env.example
  2. 10 10
      M0_VERIFICATION.md
  3. 16 2
      SPEC.md
  4. 5 5
      deploy/prometheus/prometheus.yml
  5. 14 9
      docker-compose.yml
  6. 1 1
      internal/config/config.go
  7. 3 3
      loadgen/cmd/http/main.go

+ 4 - 4
.env.example

@@ -6,10 +6,10 @@ BA_ENV=dev
 BA_LOG_LEVEL=info
 
 # HTTP addrs
-BA_INGESTD_HTTP_ADDR=:8080
-BA_ROUTERD_HTTP_ADDR=:8081
-BA_DELIVERD_HTTP_ADDR=:8082
-BA_ADMIND_HTTP_ADDR=:8083
+BA_INGESTD_HTTP_ADDR=:8800
+BA_ROUTERD_HTTP_ADDR=:8801
+BA_DELIVERD_HTTP_ADDR=:8802
+BA_ADMIND_HTTP_ADDR=:8803
 
 # Data tier
 BA_NATS_URL=nats://localhost:4222

+ 10 - 10
M0_VERIFICATION.md

@@ -38,17 +38,17 @@ in ~30s. The four app services depend on them and start last.
 ### 2. Check /health
 
 ```bash
-curl -fsS http://localhost:8080/health
-curl -fsS http://localhost:8081/health
-curl -fsS http://localhost:8082/health
-curl -fsS http://localhost:8083/health
+curl -fsS http://localhost:8800/health
+curl -fsS http://localhost:8801/health
+curl -fsS http://localhost:8802/health
+curl -fsS http://localhost:8803/health
 ```
 
 Expected: all four return `{"status":"ok","service":"..."}`.
 
 ### 3. Signed webhook end-to-end
 
-From a host that can reach ingestd (`localhost:8080` if running
+From a host that can reach ingestd (`localhost:8800` if running
 docker compose on the same host):
 
 ```bash
@@ -57,7 +57,7 @@ BODY='{"company_id":"acme-001","source_id":"prom-prod","severity":"critical","ca
 TS=$(date +%s)
 SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$SECRET" -hex | awk '{print $2}')
 
-curl -fsS -X POST http://localhost:8080/v1/ingest \
+curl -fsS -X POST http://localhost:8800/v1/ingest \
   -H "Content-Type: application/json" \
   -H "X-BA-Signature: t=$TS,v1=$SIG" \
   --data "$BODY"
@@ -75,7 +75,7 @@ Run the same call again — `dedupe_count` should be `2`.
 Same call but with `v1=deadbeef`:
 
 ```bash
-curl -i -X POST http://localhost:8080/v1/ingest \
+curl -i -X POST http://localhost:8800/v1/ingest \
   -H "X-BA-Signature: t=$TS,v1=deadbeef" \
   -H "Content-Type: application/json" \
   --data "$BODY"
@@ -87,7 +87,7 @@ Expected: `401 {"error":"bad_signature"}`.
 
 ```bash
 python3 -c 'import sys; sys.stdout.write("{\"x\":\"" + "a"*300000 + "\"}")' \
-  | curl -i -X POST http://localhost:8080/v1/ingest \
+  | curl -i -X POST http://localhost:8800/v1/ingest \
       -H "Content-Type: application/json" \
       --data-binary @-
 ```
@@ -97,7 +97,7 @@ Expected: `413 {"error":"payload_too_large"}`.
 ### 6. Schema invalid
 
 ```bash
-curl -i -X POST http://localhost:8080/v1/ingest \
+curl -i -X POST http://localhost:8800/v1/ingest \
   -H "Content-Type: application/json" \
   --data '{"company_id":"acme-001","source_id":"prom-prod","severity":"BOGUS","title":"x"}'
 ```
@@ -117,7 +117,7 @@ counter in Prometheus should be ~1500 (= 30s × 50/s).
 ### 8. Metrics
 
 ```bash
-curl -fsS http://localhost:8080/metrics | grep ba_ingestd
+curl -fsS http://localhost:8800/metrics | grep ba_ingestd
 ```
 
 Expected output:

+ 16 - 2
SPEC.md

@@ -391,6 +391,20 @@ us per-device delivery reports.
 - **Migrations**: `golang-migrate`
 - **No-code admin UI** (later): React + Vite, served by `admind`
 
+### Port conventions (project rule)
+
+- **App HTTP services** (ingestd, routerd, deliverd, admind, loadgen,
+  future services): **8800–8899**. Service picks a slot in order of
+  addition: ingestd 8800, routerd 8801, deliverd 8802, admind 8803,
+  loadgen 8891. New services pick the next free number.
+- **Canonical ports stay**: 5432 postgres, 4222 nats, 8222 nats
+  monitor, 6379 redis, 1883 mqtt, 18083 emqx admin, 8123 clickhouse
+  http, 9000 clickhouse native, 9090 prometheus, 3000 grafana.
+- Why: 8080+ collides with half the dev tooling on a workstation
+  (airplay, jenkins, …). The 8800 band is wide enough that
+  local-dev services, sidecar debuggers, and test runners all
+  have headroom.
+
 ## 19. gRPC ingest (internal high-volume sources, M11)
 
 In addition to HTTP/WS/MQTT, `ingestd` exposes a gRPC service on a
@@ -572,7 +586,7 @@ they generate load.
 
 ```bash
 loadgen-http \
-  --target https://broad-announce:8080 \
+  --target https://broad-announce:8800 \
   --api-key $SOURCE_API_KEY \
   --mode normal | stress \
   --rate 1000               # alerts/sec target per instance
@@ -585,7 +599,7 @@ loadgen-http \
   --drop-pct 0.0            # stress only: drop this % of sends
   --latency-spike-ms 0      # stress only: inject X ms of extra sleep
   --reconnect-every 0       # stress only: drop+reconnect every X seconds
-  --metrics :9091
+  --metrics :8891
   --coordinator nats://nats:4222  # for distributed mode
 ```
 

+ 5 - 5
deploy/prometheus/prometheus.yml

@@ -5,16 +5,16 @@ global:
 scrape_configs:
   - job_name: ingestd
     static_configs:
-      - targets: ['ingestd:8080']
+      - targets: ['ingestd:8800']
   - job_name: routerd
     static_configs:
-      - targets: ['routerd:8081']
+      - targets: ['routerd:8801']
   - job_name: deliverd
     static_configs:
-      - targets: ['deliverd:8082']
+      - targets: ['deliverd:8802']
   - job_name: admind
     static_configs:
-      - targets: ['admind:8083']
+      - targets: ['admind:8803']
   - job_name: loadgen
     static_configs:
-      - targets: ['loadgen-http:9091']
+      - targets: ['loadgen-http:8891']

+ 14 - 9
docker-compose.yml

@@ -1,6 +1,11 @@
 # docker-compose.yml — single-host M0 stack.
 # Run: docker compose up -d
 # Then: see M0_VERIFICATION.md for the loadgen smoke test.
+#
+# Port conventions (project rule):
+#   - app HTTP services:  8800–8899  (ingestd/routerd/deliverd/admind/loadgen)
+#   - canonical ports stay (5432 postgres, 4222 nats, 6379 redis,
+#     1883 mqtt, 9090 prometheus, 3000 grafana, etc.)
 
 services:
   # ── Data tier ────────────────────────────────────────────────────
@@ -63,14 +68,14 @@ services:
     command: ["/app/ingestd"]
     environment:
       BA_ENV: dev
-      BA_HTTP_ADDR: ":8080"
+      BA_HTTP_ADDR: ":8800"
       BA_NATS_URL: nats://nats:4222
       BA_REDIS_URL: redis://redis:6379/0
       BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
       BA_INGESTD_SOURCES: "acme-001:prom-prod:s3cret-acme,globex-002:grafana:s3cret-globex"
       BA_INGESTD_RATE_LIMIT_PER_SOURCE: "100"
       BA_INGESTD_RATE_LIMIT_PER_COMPANY: "10000"
-    ports: ["8080:8080"]
+    ports: ["8800:8800"]
     depends_on:
       nats:    { condition: service_healthy }
       redis:   { condition: service_healthy }
@@ -81,10 +86,10 @@ services:
     command: ["/app/routerd"]
     environment:
       BA_ENV: dev
-      BA_HTTP_ADDR: ":8081"
+      BA_HTTP_ADDR: ":8801"
       BA_NATS_URL: nats://nats:4222
       BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
-    ports: ["8081:8081"]
+    ports: ["8801:8801"]
     depends_on:
       nats:     { condition: service_healthy }
       postgres: { condition: service_healthy }
@@ -94,10 +99,10 @@ services:
     command: ["/app/deliverd"]
     environment:
       BA_ENV: dev
-      BA_HTTP_ADDR: ":8082"
+      BA_HTTP_ADDR: ":8802"
       BA_NATS_URL: nats://nats:4222
       BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
-    ports: ["8082:8082"]
+    ports: ["8802:8802"]
     depends_on:
       nats:     { condition: service_healthy }
       postgres: { condition: service_healthy }
@@ -107,10 +112,10 @@ services:
     command: ["/app/admind"]
     environment:
       BA_ENV: dev
-      BA_HTTP_ADDR: ":8083"
+      BA_HTTP_ADDR: ":8803"
       BA_NATS_URL: nats://nats:4222
       BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
-    ports: ["8083:8083"]
+    ports: ["8803:8803"]
     depends_on:
       nats:     { condition: service_healthy }
       postgres: { condition: service_healthy }
@@ -138,7 +143,7 @@ services:
     build: .
     command: ["/app/loadgen-http"]
     environment:
-      BA_TARGET: http://ingestd:8080
+      BA_TARGET: http://ingestd:8800
       BA_API_KEY: "acme-001:prom-prod:s3cret-acme"
       BA_RATE: "50"
       BA_DURATION: "30s"

+ 1 - 1
internal/config/config.go

@@ -39,7 +39,7 @@ func defaultCommon() Common {
 		Env:           "dev",
 		ServiceName:   "broad-announce",
 		LogLevel:      "info",
-		HTTPAddr:      ":8080",
+		HTTPAddr:      ":8800",
 		NATSURL:       envOr("BA_NATS_URL", "nats://localhost:4222"),
 		PostgresDSN:   envOr("BA_POSTGRES_DSN", "postgres://ba:ba@localhost:5432/ba?sslmode=disable"),
 		RedisURL:      envOr("BA_REDIS_URL", "redis://localhost:6379/0"),

+ 3 - 3
loadgen/cmd/http/main.go

@@ -4,7 +4,7 @@
 //
 // Example:
 //
-//	loadgen-http --target http://localhost:8080 \
+//	loadgen-http --target http://localhost:8800 \
 //	  --api-key acme-001:prom-prod:s3cret \
 //	  --mode normal --rate 100 --duration 30s
 package main
@@ -36,13 +36,13 @@ import (
 
 func main() {
 	var (
-		target     = flag.String("target", "http://localhost:8080", "ingestd base URL")
+		target     = flag.String("target", "http://localhost:8800", "ingestd base URL")
 		apiKey     = flag.String("api-key", "", "company_id:source_id:secret")
 		mode       = flag.String("mode", "normal", "profile: normal|burst|stress")
 		rate       = flag.Int("rate", 100, "target alerts/sec per instance")
 		duration   = flag.Duration("duration", 30*time.Second, "total run time")
 		conc       = flag.Int("concurrency", 16, "concurrent HTTP requests in flight")
-		metrics    = flag.String("metrics", ":9091", "Prometheus metrics listen addr (empty to disable)")
+		metrics    = flag.String("metrics", ":8891", "Prometheus metrics listen addr (empty to disable)")
 		dedupePct  = flag.Int("dedupe-pct", 30, "percent of alerts sharing a dedupe_key (normal mode)")
 		companyN   = flag.Int("companies", 1, "how many fake companies to cycle through")
 		payloadB   = flag.Int("payload-bytes", 256, "approximate payload size in bytes (Data map)")