{
  "repo": "tidbcloud/aws-shared-provider",
  "binary": "tidb-http-gateway",
  "binary_path": "cmd/tidb-http-gateway/main.go",
  "dependencies": {
    "HTTP GET /healthz": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /metrics": {
      "infrastructure": {},
      "services": []
    },
    "HTTP POST /v1beta/sql": {
      "infrastructure": {},
      "services": [
        {
          "name": "tidb-server",
          "target_interface": "MySQL Protocol",
          "operation_type": "tcp",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Connect to TiDB",
              "trigger": "Execute SQL query on backend TiDB",
              "conditions": ["Always"],
              "implementation": "poolManager.GetOrCreateByCred -> pool.Query"
            }
          ]
        }
      ]
    },
    "Runtime SQLService.HandleStatefulTxnRequest": {
      "infrastructure": {},
      "services": [
        {
          "name": "tidb-server",
          "target_interface": "MySQL Protocol",
          "operation_type": "tcp",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Begin transaction",
              "trigger": "Start transaction",
              "conditions": ["sqlType == Begin"],
              "implementation": "pool.BeginTx"
            },
            {
              "operation": "Execute query in transaction",
              "trigger": "Execute SQL in existing transaction",
              "conditions": ["session exists"],
              "implementation": "txnSession.Query"
            }
          ]
        }
      ]
    },
    "Runtime SQLService.HandleStatefulNonTxnRequest": {
      "infrastructure": {},
      "services": [
        {
          "name": "tidb-server",
          "target_interface": "MySQL Protocol",
          "operation_type": "tcp",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "Create connection",
              "trigger": "Open stateful non-txn connection",
              "conditions": ["action == open"],
              "implementation": "pool.Connect"
            },
            {
              "operation": "Execute query",
              "trigger": "Execute SQL on connection",
              "conditions": ["Always"],
              "implementation": "nonTxnSession.Query"
            },
            {
              "operation": "Close connection",
              "trigger": "Close stateful connection",
              "conditions": ["action == close"],
              "implementation": "nonTxnSession.Close"
            }
          ]
        }
      ]
    },
    "HTTP POST /v1beta/sql/proxy": {
      "infrastructure": {},
      "services": [
        {
          "name": "tidb-http-gateway",
          "target_interface": "POST /v1beta/sql/proxy",
          "operation_type": "http_post",
          "conditions": ["Stateful session needs forwarding to correct pod"],
          "operations": [
            {
              "operation": "Forward request",
              "trigger": "Forward to correct StatefulSet pod",
              "conditions": ["Session order != current pod order"],
              "implementation": "httputil.ReverseProxy to target pod"
            }
          ]
        }
      ]
    },
    "Runtime GCSession.Cleanup": {
      "infrastructure": {},
      "services": [],
      "schedule": "0/5 * * * *",
      "description": "Cleanup expired sessions every 5 minutes"
    }
  }
}
