{
  "repo": "tidbcloud/auditservice",
  "binary": "subscriber",
  "binary_path": "cmd/subscriber/main.go",
  "surface_kind": "worker_service",
  "type": "worker_service",
  "extensions": {
    "notes": [
      "The subscriber binary registers /healthz and /ping only after eventbus.Run() returns. Because RunEventBus is the normal blocking path, those HTTP routes are not part of the effective steady-state runtime surface.",
      "The real exposed surface is the EventBus consumer for auditlog.EventBusEventType."
    ]
  },
  "services": [
    {
      "name": "AuditSubscriberLifecycle",
      "package": "main",
      "methods": [
        {
          "name": "Startup",
          "name_key": "AuditSubscriberLifecycle.Startup",
          "input": "config path flag + environment variables",
          "output": "initialized eventbus, DB, AuditSvc, and registered event consumer",
          "type": "local"
        },
        {
          "name": "InitializeEventBus",
          "name_key": "AuditSubscriberLifecycle.InitializeEventBus",
          "input": "auditlog EventBus config",
          "output": "tieventbus.Eventbus instance",
          "type": "local"
        },
        {
          "name": "InitializeDB",
          "name_key": "AuditSubscriberLifecycle.InitializeDB",
          "input": "DB_DSN env var + config file path",
          "output": "gorm DB handle without migrations",
          "type": "local"
        },
        {
          "name": "InitializeAuditService",
          "name_key": "AuditSubscriberLifecycle.InitializeAuditService",
          "input": "account_svc_addr + cm_svc_addr + acl_svc_addr",
          "output": "AuditSvc backed by account, cluster-management, acl, and dao clients",
          "type": "local"
        },
        {
          "name": "RegisterEventHandler",
          "name_key": "AuditSubscriberLifecycle.RegisterEventHandler",
          "input": "EventBusEventType + ProcessAuditLog handler",
          "output": "eventbus subscription for auditlog events",
          "type": "local"
        },
        {
          "name": "RunEventBus",
          "name_key": "AuditSubscriberLifecycle.RunEventBus",
          "input": "registered eventbus handlers",
          "output": "blocking event consumer loop",
          "type": "local"
        }
      ]
    },
    {
      "name": "AuditSubscriberEvents",
      "package": "handler",
      "methods": [
        {
          "name": "Consume auditlog.EventBusEventType",
          "name_key": "Runtime AuditSubscriberEvents.ConsumeEventBusEvent",
          "input": "tieventbus.Event with Data=*auditlog.Event",
          "output": "extended and persisted audit log event or rejection",
          "type": "local"
        }
      ]
    }
  ]
}
