{
  "repo": "tidbcloud/auditservice",
  "binary": "worker",
  "binary_path": "cmd/worker/main.go",
  "surface_kind": "mixed_service",
  "type": "mixed_service",
  "extensions": {
    "notes": [
      "DeleteOldEvents only performs deletion when server.clearAuditLogWhitelist is configured; an empty whitelist causes the task to log and return without deleting anything.",
      "Unlike subscriber, worker starts the scheduler asynchronously and then starts the health server, so /healthz and /ping are part of the steady-state runtime surface."
    ]
  },
  "services": [
    {
      "name": "AuditWorkerLifecycle",
      "package": "main",
      "methods": [
        {
          "name": "Startup",
          "name_key": "AuditWorkerLifecycle.Startup",
          "input": "config path flag + environment variables",
          "output": "loaded remote config, initialized DB, scheduled cleanup, and running health server",
          "type": "local"
        },
        {
          "name": "LoadRemoteConfig",
          "name_key": "AuditWorkerLifecycle.LoadRemoteConfig",
          "input": "oneconfig-account/config.yaml",
          "output": "viper-backed remote config plus background watcher",
          "type": "local"
        },
        {
          "name": "InitializeDB",
          "name_key": "AuditWorkerLifecycle.InitializeDB",
          "input": "DB_DSN env var",
          "output": "gorm DB handle with migrations enabled",
          "type": "local"
        },
        {
          "name": "ScheduleDeleteOldEvents",
          "name_key": "AuditWorkerLifecycle.ScheduleDeleteOldEvents",
          "input": "gocron scheduler",
          "output": "daily DeleteOldEvents job",
          "type": "local"
        },
        {
          "name": "StartScheduler",
          "name_key": "AuditWorkerLifecycle.StartScheduler",
          "input": "configured scheduler",
          "output": "background async job loop",
          "type": "local"
        },
        {
          "name": "StartHTTPServer",
          "name_key": "AuditWorkerLifecycle.StartHTTPServer",
          "input": "fixed address 0.0.0.0:11000",
          "output": "running health server",
          "type": "local"
        }
      ]
    },
    {
      "name": "AuditWorkerHTTP",
      "type": "http",
      "methods": [
        {
          "name": "GET /healthz",
          "name_key": "HTTP GET /healthz",
          "input": "none",
          "output": "pong",
          "path": "/healthz",
          "type": "http"
        },
        {
          "name": "GET /ping",
          "name_key": "HTTP GET /ping",
          "input": "none",
          "output": "pong",
          "path": "/ping",
          "type": "http"
        }
      ]
    },
    {
      "name": "AuditWorkerTasks",
      "package": "tasks",
      "methods": [
        {
          "name": "DeleteOldEvents",
          "name_key": "AuditWorkerTasks.DeleteOldEvents",
          "input": "server.clearAuditLogWhitelist remote config",
          "output": "hard delete of old audit events outside the whitelist",
          "type": "local"
        }
      ]
    }
  ]
}
