{
  "repo": "tidbcloud/dataservices",
  "binary": "dataapi_gateway",
  "binary_path": "cmd/dataapi_gateway/main.go",
  "dependencies": {
    "DataAPIGatewayLifecycle.LoadConfigAndLogger": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "Always at process startup"
          ],
          "operations": [
            {
              "operation": "READ FILE",
              "trigger": "Load the regional service config before any client or listener is initialized",
              "conditions": [
                "Always"
              ],
              "implementation": "config.InitConfig(configPath)"
            }
          ]
        }
      },
      "services": []
    },
    "DataAPIGatewayLifecycle.RegisterMetricsAndRBACConfig": {
      "infrastructure": {},
      "services": []
    },
    "DataAPIGatewayLifecycle.InitRegionalCaches": {
      "infrastructure": {
        "redis": {
          "conditions": [
            "Only when AliCloud regional mode is disabled"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Initialize the shared Redis client and register the Redis-backed session driver",
              "conditions": [
                "!config.IsAliCloudRegionalMode()"
              ],
              "implementation": "redisutil.NewRedisClient(ctx, config); sessioncache.RegisterRedisDriver(ctx)"
            }
          ]
        },
        "dynamodb": {
          "conditions": [
            "Only when AliCloud regional mode is disabled"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Initialize DynamoDB-backed configuration and permission lookups used by the gateway",
              "conditions": [
                "!config.IsAliCloudRegionalMode()"
              ],
              "implementation": "ddb.Init(ctx, config)"
            }
          ]
        }
      },
      "services": []
    },
    "DataAPIGatewayLifecycle.InitCustomLogger": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "Only when the custom log file path can be opened successfully"
          ],
          "operations": [
            {
              "operation": "OPEN FILE",
              "trigger": "Create the rolling JSON log file used for endpoint execution audit logs",
              "conditions": [
                "config.CustomLogWriteConf.LogDir and FileName resolve to a writable path"
              ],
              "implementation": "InitCustomLogger -> log.InitLogger(&pingcapLogCfg)"
            }
          ]
        }
      },
      "services": []
    },
    "DataAPIGatewayLifecycle.StartUnauthMetricsLoop": {
      "infrastructure": {
        "redis": {
          "conditions": [
            "Only when AliCloud regional mode is disabled and Redis initialization succeeded"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the dedicated Redis client used to pull unauthenticated-request counters",
              "conditions": [
                "!config.IsAliCloudRegionalMode()"
              ],
              "implementation": "StartUnauthMetricsLoop -> initUnauthRedis -> redis.NewClient(...).Ping(ctx)"
            },
            {
              "operation": "HGETALL + DEL",
              "trigger": "Pull and clear the current unauthenticated-request counters each interval",
              "conditions": [
                "!config.IsAliCloudRegionalMode()",
                "The background loop is running"
              ],
              "implementation": "fetchUnauthMetrics -> pipe.HGetAll(...); pipe.Del(...); pipe.Exec(ctx)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "dynamodb-custom-domain-store",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "repository_ddb.ListCustomDomains",
          "operation_type": "ddb_query",
          "conditions": [
            "Only for unauth records whose host is not under *.tidbcloud.com"
          ],
          "operations": [
            {
              "operation": "LOOK UP CUSTOM DOMAIN",
              "trigger": "Map a custom-domain unauth record back to the owning external app id before incrementing the metric",
              "conditions": [
                "host does not end with .tidbcloud.com"
              ],
              "implementation": "handleCustomDomainUnauth -> service.ListCustomDomains(context.Background(), host) -> repository_ddb.ListCustomDomains(ctx, ddb.Client(), customDomainName)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayLifecycle.RegisterKubeResolver": {
      "infrastructure": {
        "kubernetes_dns": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "REGISTER RESOLVER",
              "trigger": "Enable gRPC client-side service discovery for executor service addresses",
              "conditions": [
                "Always"
              ],
              "implementation": "kuberesolver.RegisterInCluster()"
            }
          ]
        }
      },
      "services": []
    },
    "DataAPIGatewayLifecycle.StartTracing": {
      "infrastructure": {},
      "services": []
    },
    "DataAPIGatewayLifecycle.StartMetricsServer": {
      "infrastructure": {},
      "services": []
    },
    "DataAPIGatewayLifecycle.RegisterHTTPRoutes": {
      "infrastructure": {},
      "services": []
    },
    "DataAPIGatewayLifecycle.RegisterGrpcServices": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.*",
          "operation_type": "grpc_connect",
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "CREATE DEFAULT gRPC CONNECTION",
              "trigger": "Build the long-lived executor client before registering the gateway gRPC service implementation",
              "conditions": [
                "Always"
              ],
              "implementation": "CreateDataAPIGatewayService -> server.init -> newExecutorClient(c.cfg.ExecutorSvcAddr) -> newGrpcConn(addr)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayLifecycle.StartHTTPAndGRPCServers": {
      "infrastructure": {
        "tcp": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "LISTEN",
              "trigger": "Expose the Gin listener and the gRPC listener",
              "conditions": [
                "Always"
              ],
              "implementation": "startupHttp -> ginEng.Run(addr); startupGRPC -> net.Listen(\"tcp\", \":\"+GrpcPort); grpcServer.Serve(listen)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP GET /healthz": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /api/v1beta/app/:external_app_id/endpoint/*path": {
      "infrastructure": {
        "dynamodb": {
          "conditions": [
            "Only after the request passes Kong auth and the endpoint lookup path is reached"
          ],
          "operations": [
            {
              "operation": "LOOK UP DATAAPP + ENDPOINT",
              "trigger": "Resolve the external app id and endpoint path into a deployed or draft endpoint configuration",
              "conditions": [
                "!config.Global().IsAliCloudRegionalMode()",
                "kong.GetOpenAPIAuthResult(c.Request) succeeds"
              ],
              "implementation": "handleQuery -> GetEndpoint -> service.GetDataAppByExtId / service.GetDeployedEndpointByPath"
            }
          ]
        }
      },
      "services": [
        {
          "name": "region-api-key-rbac",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "useadapter.CheckApiKeyPermission / CheckRegionApiKeyPermission",
          "operation_type": "rbac_check",
          "conditions": [
            "Only for non-local mode and non-chat2query endpoints"
          ],
          "operations": [
            {
              "operation": "CHECK API KEY PERMISSION",
              "trigger": "Verify that the caller public key is allowed to execute the endpoint in its current RW mode",
              "conditions": [
                "!config.IsLocalMode()",
                "!isChat2QueryAppEndpoint(entityEndpoint)"
              ],
              "implementation": "handleQuery -> service.CheckApiKeyPermission(ctx, entityEndpoint.DataappId, entityEndpoint.ClusterId, entityEndpoint.RWMode, publicKey)"
            }
          ]
        },
        {
          "name": "regional-gateway-redirect",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "Regional HTTP gateway",
          "operation_type": "http_redirect",
          "conditions": [
            "Only for non-chat2query endpoints when gateway redirect is enabled and the target cluster belongs to another region"
          ],
          "operations": [
            {
              "operation": "HTTP 307 REDIRECT",
              "trigger": "Bounce the request to the target regional gateway instead of executing it locally",
              "conditions": [
                "config.Global().RegionalConf.GatewayRedirect == true",
                "Redirect(...) returns redirect == true"
              ],
              "implementation": "handleQuery -> Redirect(ctx, c, entityApp.ProjectId, entityEndpoint.ClusterId, true)"
            }
          ]
        },
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when the request is not redirected and resolves to a regular SQL endpoint"
          ],
          "operations": [
            {
              "operation": "EXEC SQL",
              "trigger": "Execute the resolved endpoint against the regional executor after permission and cluster checks pass",
              "conditions": [
                "!isChat2QueryAppEndpoint(entityEndpoint)",
                "Redirect(...) did not short-circuit",
                "service.HasClusterPermission(...) == true",
                "ExecEndpoints(...) is reached"
              ],
              "implementation": "handleQuery -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... dataapi.NewDataAPIExecutorServiceClient(conn).ExecSql ...)"
            }
          ]
        }
      ]
    },
    "HTTP POST /api/v1beta/app/:external_app_id/endpoint/*path": {
      "infrastructure": {},
      "services": [
        {
          "name": "region-api-key-rbac",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "useadapter.CheckApiKeyPermission / CheckRegionApiKeyPermission",
          "operation_type": "rbac_check",
          "conditions": [
            "Only for non-local mode and non-chat2query endpoints"
          ],
          "operations": [
            {
              "operation": "CHECK API KEY PERMISSION",
              "trigger": "Same implementation chain as the GET public endpoint path",
              "conditions": [
                "Same conditions as GET /api/v1beta/app/:external_app_id/endpoint/*path"
              ],
              "implementation": "Advanced -> handleQuery -> service.CheckApiKeyPermission(...)"
            }
          ]
        },
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when request routing, permission, and redirect checks all pass"
          ],
          "operations": [
            {
              "operation": "EXEC SQL",
              "trigger": "Same implementation chain as the GET public endpoint path",
              "conditions": [
                "Same conditions as GET /api/v1beta/app/:external_app_id/endpoint/*path"
              ],
              "implementation": "Advanced -> handleQuery -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... ExecSql ...)"
            }
          ]
        }
      ]
    },
    "HTTP PUT /api/v1beta/app/:external_app_id/endpoint/*path": {
      "infrastructure": {},
      "services": [
        {
          "name": "region-api-key-rbac",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "useadapter.CheckApiKeyPermission / CheckRegionApiKeyPermission",
          "operation_type": "rbac_check",
          "conditions": [
            "Only for non-local mode and non-chat2query endpoints"
          ],
          "operations": [
            {
              "operation": "CHECK API KEY PERMISSION",
              "trigger": "Same implementation chain as the GET public endpoint path",
              "conditions": [
                "Same conditions as GET /api/v1beta/app/:external_app_id/endpoint/*path"
              ],
              "implementation": "Advanced -> handleQuery -> service.CheckApiKeyPermission(...)"
            }
          ]
        },
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when request routing, permission, and redirect checks all pass"
          ],
          "operations": [
            {
              "operation": "EXEC SQL",
              "trigger": "Same implementation chain as the GET public endpoint path",
              "conditions": [
                "Same conditions as GET /api/v1beta/app/:external_app_id/endpoint/*path"
              ],
              "implementation": "Advanced -> handleQuery -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... ExecSql ...)"
            }
          ]
        }
      ]
    },
    "HTTP DELETE /api/v1beta/app/:external_app_id/endpoint/*path": {
      "infrastructure": {},
      "services": [
        {
          "name": "region-api-key-rbac",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "useadapter.CheckApiKeyPermission / CheckRegionApiKeyPermission",
          "operation_type": "rbac_check",
          "conditions": [
            "Only for non-local mode and non-chat2query endpoints"
          ],
          "operations": [
            {
              "operation": "CHECK API KEY PERMISSION",
              "trigger": "Same implementation chain as the GET public endpoint path",
              "conditions": [
                "Same conditions as GET /api/v1beta/app/:external_app_id/endpoint/*path"
              ],
              "implementation": "Advanced -> handleQuery -> service.CheckApiKeyPermission(...)"
            }
          ]
        },
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when request routing, permission, and redirect checks all pass"
          ],
          "operations": [
            {
              "operation": "EXEC SQL",
              "trigger": "Same implementation chain as the GET public endpoint path",
              "conditions": [
                "Same conditions as GET /api/v1beta/app/:external_app_id/endpoint/*path"
              ],
              "implementation": "Advanced -> handleQuery -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... ExecSql ...)"
            }
          ]
        }
      ]
    },
    "HTTP PATCH /api/v1beta/app/:external_app_id/endpoint/*path": {
      "infrastructure": {},
      "services": []
    },
    "HTTP HEAD /api/v1beta/app/:external_app_id/endpoint/*path": {
      "infrastructure": {},
      "services": []
    },
    "HTTP OPTIONS /api/v1beta/app/:external_app_id/endpoint/*path": {
      "infrastructure": {},
      "services": []
    },
    "HTTP POST /inner/dataservice/v2/endpoint/test": {
      "infrastructure": {
        "dynamodb": {
          "conditions": [
            "Only when host guard and optional inner basic auth both pass"
          ],
          "operations": [
            {
              "operation": "LOOK UP DRAFT ENDPOINT",
              "trigger": "Resolve the test endpoint id before execution",
              "conditions": [
                "GlobalDataAPIService.TestEndpointV2 is called"
              ],
              "implementation": "TestEndpointV2 -> GlobalDataAPIService.TestEndpointV2 -> GetTestEndpointById -> service.GetDraftEndpoint(ctx, endpointId)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when draft endpoint resolution and argument parsing both succeed"
          ],
          "operations": [
            {
              "operation": "EXEC TEST ENDPOINT",
              "trigger": "Run the draft endpoint through the executor and return the advanced result",
              "conditions": [
                "GetTestEndpointById succeeded",
                "buildEndpointArgs and parseParamsWithEndpoint succeeded"
              ],
              "implementation": "GlobalDataAPIService.TestEndpointV2 -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... ExecSql ...)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/v2/exec/sqltemplate": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when body parsing and DTO-to-proto conversion succeed"
          ],
          "operations": [
            {
              "operation": "EXEC SQL TEMPLATE",
              "trigger": "Forward the inner SQL-template request to the executor path through the gateway gRPC service",
              "conditions": [
                "parseParamFromBody succeeded",
                "dto.ConvertExecSqlReqToProtoV2 succeeded"
              ],
              "implementation": "ExecSqlTemplateV2 -> GlobalDataAPIService.ExecSqlTemplateV2 -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... ExecSql ...)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/exec/sql": {
      "infrastructure": {
        "redis": {
          "conditions": [
            "Only when session-backed dispatch is enabled and SessionId is non-empty"
          ],
          "operations": [
            {
              "operation": "LOAD SESSION",
              "trigger": "Populate req.SessionItem so the executor can be pinned to the right endpoint",
              "conditions": [
                "req.SessionId != \"\"",
                "config.Global().IsAliCloudRegionalMode() == false"
              ],
              "implementation": "GlobalDataAPIService.ExecSql -> dispatchStrategy.PrepareExecReq -> fillSessionForExecReq -> getSessionItem -> sessionItem.Load(ctx)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when body parsing succeeds"
          ],
          "operations": [
            {
              "operation": "EXEC SQL",
              "trigger": "Forward the inner raw SQL request to the executor, optionally with endpoint-affinity call options",
              "conditions": [
                "parseParamFromBody succeeded",
                "dto.ConvertExecSqlReqToProto succeeded"
              ],
              "implementation": "ExecSql -> GlobalDataAPIService.ExecSql -> executorClient.Exec(... dataapi.NewDataAPIExecutorServiceClient(conn).ExecSql ...)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/app_id_cluster_permission_check": {
      "infrastructure": {
        "dynamodb": {
          "conditions": [
            "Only when cache miss reaches repository_ddb"
          ],
          "operations": [
            {
              "operation": "LOOK UP APP-CLUSTER PERMISSION",
              "trigger": "Check whether the dataapp has permission to touch the requested cluster",
              "conditions": [
                "parseParamFromBody succeeded"
              ],
              "implementation": "CheckAppIDClusterPermission -> service.HasClusterPermission -> repository_ddb.GetAppCluster(ctx, ddb.Client(), dataappID, clusterID)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP POST /inner/dataservice/database/meta": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.GetDatabaseMeta",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when body parsing and DTO-to-proto conversion succeed"
          ],
          "operations": [
            {
              "operation": "GET DATABASE META",
              "trigger": "Forward the metadata request to the executor",
              "conditions": [
                "parseParamFromBody succeeded",
                "dto.ConvertGetDatabaseMetaReqToProto succeeded"
              ],
              "implementation": "GetDatabaseMeta -> GlobalDataAPIService.GetDatabaseMeta -> dataapi.NewDataAPIExecutorServiceClient(c.executorClient.Get()).GetDatabaseMeta(ctx, in)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/session/create": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.CreateSession",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when body parsing and DTO-to-proto conversion succeed"
          ],
          "operations": [
            {
              "operation": "CREATE SESSION",
              "trigger": "Open an executor-side SQL session",
              "conditions": [
                "parseParamFromBody succeeded",
                "dto.ConvertCreateSessionReqToProto succeeded"
              ],
              "implementation": "CreateSession -> GlobalDataAPIService.CreateSession -> dataapi.NewDataAPIExecutorServiceClient(c.executorClient.Get()).CreateSession(ctx, in)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/session/close": {
      "infrastructure": {
        "redis": {
          "conditions": [
            "Only when session-backed dispatch is enabled and the session id can be resolved from Redis"
          ],
          "operations": [
            {
              "operation": "LOAD SESSION",
              "trigger": "Recover the executor endpoint for session-affine close requests",
              "conditions": [
                "config.Global().IsAliCloudRegionalMode() == false"
              ],
              "implementation": "GlobalDataAPIService.CloseSession -> dispatchStrategy.PrepareCloseReq -> fillSessionForCloseReq -> getSessionItem -> sessionItem.Load(ctx)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.CloseSession",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when body parsing and DTO-to-proto conversion succeed"
          ],
          "operations": [
            {
              "operation": "CLOSE SESSION",
              "trigger": "Forward the close request to the executor, using endpoint affinity when available",
              "conditions": [
                "parseParamFromBody succeeded",
                "dto.ConvertCloseSessionReqToProto succeeded"
              ],
              "implementation": "CloseSession -> GlobalDataAPIService.CloseSession -> executorClient.Exec(... dataapi.NewDataAPIExecutorServiceClient(conn).CloseSession ...)"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/parse/stmt": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ParseOneStmt",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when body parsing succeeds"
          ],
          "operations": [
            {
              "operation": "PARSE SQL",
              "trigger": "Ask the executor to parse a single SQL statement",
              "conditions": [
                "parseParamFromBody succeeded"
              ],
              "implementation": "ParseOneStmt -> GlobalDataAPIService.ParseOneStmt -> dataapi.NewDataAPIExecutorServiceClient(c.executorClient.Get()).ParseOneStmt(ctx, &dataapi.ParseOneStmtReq{Sql: req.Sql})"
            }
          ]
        }
      ]
    },
    "HTTP POST /inner/dataservice/v2/resolvehost": {
      "infrastructure": {
        "dns": {
          "conditions": [
            "Only when the host query parameter is non-empty"
          ],
          "operations": [
            {
              "operation": "RESOLVE HOST",
              "trigger": "Resolve the requested host to an IP address for connectivity diagnostics",
              "conditions": [
                "host != \"\""
              ],
              "implementation": "ResolveHost -> resolveHostIp(host) -> net.ResolveIPAddr(\"ip\", host)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP GET /metrics": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /custom-metrics": {
      "infrastructure": {},
      "services": []
    },
    "DataAPIGatewayService.TestEndpointV2": {
      "infrastructure": {
        "dynamodb": {
          "conditions": [
            "Only when the draft endpoint cache misses or the endpoint id is not yet in memory"
          ],
          "operations": [
            {
              "operation": "LOOK UP DRAFT ENDPOINT",
              "trigger": "Resolve the draft endpoint definition by id before testing it",
              "conditions": [
                "Always"
              ],
              "implementation": "GetTestEndpointById -> service.GetDraftEndpoint(ctx, endpointId)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when endpoint lookup and argument parsing succeed"
          ],
          "operations": [
            {
              "operation": "EXEC TEST ENDPOINT",
              "trigger": "Execute the draft endpoint through the shared endpoint executor path",
              "conditions": [
                "GetTestEndpointById succeeded",
                "buildEndpointArgs succeeded",
                "parseParamsWithEndpoint succeeded"
              ],
              "implementation": "TestEndpointV2 -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... ExecSql ...)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayService.ExecSqlTemplateV2": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Only when endpoint argument parsing succeeds"
          ],
          "operations": [
            {
              "operation": "EXEC SQL TEMPLATE",
              "trigger": "Translate template args into endpoint.exec input and forward to the executor",
              "conditions": [
                "buildEndpointArgs succeeded"
              ],
              "implementation": "ExecSqlTemplateV2 -> ExecEndpoints -> endpoint.exec -> executorClient.Exec(... ExecSql ...)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayService.ExecSql": {
      "infrastructure": {
        "redis": {
          "conditions": [
            "Only in RedisSessionDispatchStrategy and only when SessionId is non-empty"
          ],
          "operations": [
            {
              "operation": "LOAD SESSION",
              "trigger": "Load the persisted session item so the request can reuse executor affinity",
              "conditions": [
                "req.SessionId != \"\"",
                "NewExecutorDispatchStrategy() returned RedisSessionDispatchStrategy"
              ],
              "implementation": "ExecSql -> dispatchStrategy.PrepareExecReq -> fillSessionForExecReq -> getSessionItem -> sessionItem.Load(ctx)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ExecSql",
          "operation_type": "grpc_unary",
          "conditions": [
            "Always after the dispatch strategy finishes request preparation"
          ],
          "operations": [
            {
              "operation": "EXEC SQL",
              "trigger": "Forward the request to a session-affine executor endpoint when possible, otherwise use the default executor service connection",
              "conditions": [
                "Always"
              ],
              "implementation": "ExecSql -> executorClient.Exec(ctx, handler, dispatchStrategy.ExecCallOptions(req)...)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayService.GetDatabaseMeta": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.GetDatabaseMeta",
          "operation_type": "grpc_unary",
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "GET DATABASE META",
              "trigger": "Forward the metadata request over the default executor client connection",
              "conditions": [
                "Always"
              ],
              "implementation": "GetDatabaseMeta -> dataapi.NewDataAPIExecutorServiceClient(c.executorClient.Get()).GetDatabaseMeta(ctx, in)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayService.CreateSession": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.CreateSession",
          "operation_type": "grpc_unary",
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "CREATE SESSION",
              "trigger": "Open a SQL session through the default executor service connection",
              "conditions": [
                "Always"
              ],
              "implementation": "CreateSession -> dataapi.NewDataAPIExecutorServiceClient(c.executorClient.Get()).CreateSession(ctx, in)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayService.CloseSession": {
      "infrastructure": {
        "redis": {
          "conditions": [
            "Only in RedisSessionDispatchStrategy when the session id is provided"
          ],
          "operations": [
            {
              "operation": "LOAD SESSION",
              "trigger": "Recover the session's executor endpoint before forwarding the close request",
              "conditions": [
                "req.SessionId != \"\"",
                "NewExecutorDispatchStrategy() returned RedisSessionDispatchStrategy"
              ],
              "implementation": "CloseSession -> dispatchStrategy.PrepareCloseReq -> fillSessionForCloseReq -> getSessionItem -> sessionItem.Load(ctx)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.CloseSession",
          "operation_type": "grpc_unary",
          "conditions": [
            "Always after dispatch-strategy preparation"
          ],
          "operations": [
            {
              "operation": "CLOSE SESSION",
              "trigger": "Forward the close request to the session-affine executor when possible",
              "conditions": [
                "Always"
              ],
              "implementation": "CloseSession -> executorClient.Exec(ctx, handler, dispatchStrategy.CloseCallOptions(req)...)"
            }
          ]
        }
      ]
    },
    "DataAPIGatewayService.ParseOneStmt": {
      "infrastructure": {},
      "services": [
        {
          "name": "dataapi-executor",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIExecutorService.ParseOneStmt",
          "operation_type": "grpc_unary",
          "conditions": [
            "Always"
          ],
          "operations": [
            {
              "operation": "PARSE SQL",
              "trigger": "Delegate single-statement parsing to the executor service",
              "conditions": [
                "Always"
              ],
              "implementation": "ParseOneStmt -> dataapi.NewDataAPIExecutorServiceClient(c.executorClient.Get()).ParseOneStmt(ctx, in)"
            }
          ]
        }
      ]
    }
  }
}
