{
  "repo": "tidbcloud/devtier-store-service",
  "binary": "billing",
  "binary_path": "cmd/billing/main.go",
  "surface_kind": "mixed_service",
  "type": "mixed_service",
  "extensions": {
    "notes": [
      "Fresh codex rescan rebuilt billing from source. The binary is not just a tag-trigger HTTP shim; it also initializes AWS role-backed S3 access, registers four cron jobs, performs two cold-start backfills, and exposes a separate Prometheus listener on :9090.",
      "Conditions are material in this binary: route behavior depends on the :tag path value, GCP BigQuery access is prod-only, the tenant-access CSV bootstrap only happens on the first day of a month, and several loops retry up to three times before giving up."
    ]
  },
  "services": [
    {
      "name": "BillingLifecycle",
      "package": "cmd/billing",
      "methods": [
        {
          "name": "AwsRoleInit",
          "name_key": "BillingLifecycle.AwsRoleInit",
          "input": "process environment",
          "output": "Env, K8sNsPrefix, AWS role, and shared S3 client initialized",
          "type": "local"
        },
        {
          "name": "RegisterDailyCostCron",
          "name_key": "BillingLifecycle.RegisterDailyCostCron",
          "input": "cron scheduler",
          "output": "08:00 daily-cost job registered",
          "type": "local"
        },
        {
          "name": "RegisterCloudTenantsCron",
          "name_key": "BillingLifecycle.RegisterCloudTenantsCron",
          "input": "cron scheduler",
          "output": "00:00 cloud-tenant sync job registered",
          "type": "local"
        },
        {
          "name": "RegisterTenantAccessInfoCron",
          "name_key": "BillingLifecycle.RegisterTenantAccessInfoCron",
          "input": "cron scheduler",
          "output": "01:00 tenant-access export job registered",
          "type": "local"
        },
        {
          "name": "RegisterActiveClustersCron",
          "name_key": "BillingLifecycle.RegisterActiveClustersCron",
          "input": "cron scheduler",
          "output": "02:00 active-cluster refresh job registered",
          "type": "local"
        },
        {
          "name": "StartCronScheduler",
          "name_key": "BillingLifecycle.StartCronScheduler",
          "input": "cron scheduler",
          "output": "background cron loop started",
          "type": "local"
        },
        {
          "name": "StartMetricsServer",
          "name_key": "BillingLifecycle.StartMetricsServer",
          "input": "logger",
          "output": "Prometheus listener on :9090 started",
          "type": "local"
        },
        {
          "name": "BootstrapDailyCost",
          "name_key": "BillingLifecycle.BootstrapDailyCost",
          "input": "none",
          "output": "immediate daily-cost refresh kicked off at startup",
          "type": "local"
        },
        {
          "name": "BootstrapActiveClusters",
          "name_key": "BillingLifecycle.BootstrapActiveClusters",
          "input": "none",
          "output": "immediate active-cluster refresh kicked off at startup",
          "type": "local"
        },
        {
          "name": "StartHTTPServer",
          "name_key": "BillingLifecycle.StartHTTPServer",
          "input": "Gin engine",
          "output": "HTTP listener on :8888 started",
          "type": "local"
        }
      ]
    },
    {
      "name": "BillingMetricsHTTP",
      "package": "utils/metric",
      "methods": [
        {
          "name": "GetMetrics",
          "name_key": "BillingMetricsHTTP.GetMetrics",
          "input": "Prometheus scrape request",
          "output": "serverless_billing gauge values",
          "type": "http",
          "http_method": "GET",
          "http_path": "/metrics"
        }
      ]
    },
    {
      "name": "BillingHTTP",
      "package": "cmd/billing",
      "methods": [
        {
          "name": "TriggerTagJob",
          "name_key": "BillingHTTP.TriggerTagJob",
          "input": "tag path param",
          "output": "well done!",
          "type": "http",
          "http_method": "GET",
          "http_path": "/:tag"
        },
        {
          "name": "CreateS3Object",
          "name_key": "BillingHTTP.CreateS3Object",
          "input": "bucket, dir, key path params",
          "output": "well done",
          "type": "http",
          "http_method": "GET",
          "http_path": "/s3/:bucket/:dir/:key"
        }
      ]
    },
    {
      "name": "BillingJobs",
      "package": "cmd/billing",
      "methods": [
        {
          "name": "FetchServerlessDailyCost",
          "name_key": "BillingJobs.FetchServerlessDailyCost",
          "input": "none",
          "output": "daily cost refresh attempted up to three times",
          "type": "local"
        },
        {
          "name": "ProcessCostSnapshot",
          "name_key": "BillingJobs.ProcessCostSnapshot",
          "input": "logger",
          "output": "daily cost snapshot and S3 exports refreshed",
          "type": "local"
        },
        {
          "name": "UpdateServerlessDb",
          "name_key": "BillingJobs.UpdateServerlessDb",
          "input": "logger, offset days",
          "output": "regional cost tables updated in MySQL",
          "type": "local"
        },
        {
          "name": "FetchCloudTenants",
          "name_key": "BillingJobs.FetchCloudTenants",
          "input": "none",
          "output": "new GCP tenants synced into tenant_meta",
          "type": "local"
        },
        {
          "name": "FetchServerlessTenantAccessInfo",
          "name_key": "BillingJobs.FetchServerlessTenantAccessInfo",
          "input": "none",
          "output": "tenant activity CSV appended to S3",
          "type": "local"
        },
        {
          "name": "FetchServerlessActiveClusters",
          "name_key": "BillingJobs.FetchServerlessActiveClusters",
          "input": "none",
          "output": "active-cluster counts refreshed into MySQL and Prometheus gauges",
          "type": "local"
        }
      ]
    }
  ]
}
