CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (pull_request) Canceled after 0s
CI / Core-Modul (Build/Vet/Test) (pull_request) Failing after 1m0s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (pull_request) Successful in 5s
CI / Connect Security-Test-Gate (QA-01 AC4, Merge-Gate) (pull_request) Successful in 4s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (pull_request) Failing after 21s
CI / Web (dms-browser) (pull_request) Failing after 1m27s
CI / Web (pdf-viewer) (pull_request) Failing after 1m2s
CI / Web (shl) (pull_request) Failing after 11s
CI / Core-Modul (Build/Vet/Test) (push) Failing after 1m0s
CI / DMS Security-Test-Gate (AC5, Merge-Gate) (push) Successful in 5s
CI / Connect Security-Test-Gate (QA-01 AC4, Merge-Gate) (push) Successful in 4s
CI / DMS-Modul Supply-Chain-Scan (govulncheck) (push) Failing after 19s
CI / Web (dms-browser) (push) Failing after 1m26s
CI / Web (pdf-viewer) (push) Failing after 1m3s
CI / Web (shl) (push) Failing after 11s
Core-Schnittstellen-Vertragstests / contract-tests (pull_request) Successful in 13m12s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (pull_request) Canceled after 0s
CI / DMS-Modul (Lint/Build/Test/Coverage/Artefakt) (push) Canceled after 0s
CI / Web-Barrierefreiheitspruefung (axe, Tastatur, Reflow, Textabstaende) (push) Canceled after 0s
DB-Integrationstests / db-tests (pull_request) Canceled after 0s
Supply-Chain-Scan (Go) / govulncheck (push) Canceled after 0s
Supply-Chain-Scan (Go) / govulncheck (pull_request) Canceled after 0s
Supply-Chain-Scan (npm) / npm-audit (pull_request) Canceled after 0s
Core-Pflichttest-Gate / pflichttest-gate (pull_request) Canceled after 0s
RBAC-Rollenhierarchie-Pflichtgate / rbac-policy-invariant (pull_request) Canceled after 0s
Core-Schnittstellen-Vertragstests / contract-tests (push) Successful in 12m23s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
72 lines
2.4 KiB
Go
72 lines
2.4 KiB
Go
// resync-api ist der Aufrufpunkt fuer API-11: startet den bereits
|
|
// fertigen internal/resync.Handler (API-06) als eigenstaendigen
|
|
// HTTP-Dienst. REINES WIRING — keine Aenderung an internal/resync/,
|
|
// internal/audit/, internal/usage/ oder internal/moduleregistry/.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
|
|
"gitea.perlbach24.de/scripte/nexarch/common/httpharden"
|
|
"gitea.perlbach24.de/scripte/nexarch/internal/audit"
|
|
"gitea.perlbach24.de/scripte/nexarch/internal/flag"
|
|
"gitea.perlbach24.de/scripte/nexarch/internal/moduleregistry"
|
|
"gitea.perlbach24.de/scripte/nexarch/internal/resync"
|
|
"gitea.perlbach24.de/scripte/nexarch/internal/usage"
|
|
)
|
|
|
|
// auditAdapter erfüllt resync.AuditRecorder über den bestehenden
|
|
// audit.Log-Schreibpfad — kein neuer Audit-Code, nur Signatur-Anpassung
|
|
// (audit.Log.Record nimmt ein Event-Struct, resync.AuditRecorder einzelne
|
|
// Felder).
|
|
type auditAdapter struct{ log *audit.Log }
|
|
|
|
func (a auditAdapter) Record(ctx context.Context, tenantSlug, actor, action, target string, metadata map[string]any, occurredAt time.Time) error {
|
|
return a.log.Record(ctx, audit.Event{
|
|
TenantSlug: tenantSlug, Actor: actor, Action: action, Target: target,
|
|
Metadata: metadata, OccurredAt: occurredAt,
|
|
})
|
|
}
|
|
|
|
func main() {
|
|
registryDSN := os.Getenv("NEXARCH_RESYNC_REGISTRY_DSN")
|
|
if registryDSN == "" {
|
|
log.Fatal("NEXARCH_RESYNC_REGISTRY_DSN muss gesetzt sein")
|
|
}
|
|
addr := os.Getenv("NEXARCH_RESYNC_API_LISTEN_ADDR")
|
|
if addr == "" {
|
|
addr = "127.0.0.1:8098"
|
|
}
|
|
|
|
ctx := context.Background()
|
|
pool, err := pgxpool.New(ctx, registryDSN)
|
|
if err != nil {
|
|
log.Fatalf("datenbankverbindung: %v", err)
|
|
}
|
|
defer pool.Close()
|
|
|
|
flagStore := flag.NewStore(pool)
|
|
flagService := flag.NewService(flagStore, 30*time.Second)
|
|
registry := moduleregistry.NewRegistry(pool, flagService)
|
|
auditLog := audit.NewLog(pool)
|
|
usageStore := usage.NewStore(pool)
|
|
|
|
handler := resync.NewHandler(registry, auditAdapter{log: auditLog}, usageStore)
|
|
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("/internal/resync/audit", handler.AuditHandler)
|
|
mux.HandleFunc("/internal/resync/usage", handler.UsageHandler)
|
|
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) })
|
|
|
|
log.Printf("resync-api: listening on %s", addr)
|
|
if err := httpharden.ListenAndServe(addr, mux); err != nil {
|
|
log.Fatalf("http server: %v", err)
|
|
}
|
|
}
|