{
  "repo": "tidbcloud/aws-shared-provider",
  "binary": "meta-server",
  "binary_path": "cmd/meta-server/main.go",
  "dependencies": {
    "MetaServerLifecycle.LoadFlags": {
      "infrastructure": {},
      "services": []
    },
    "MetaServerLifecycle.InitTLSConfig": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "--cacert, --cert, or --key paths are configured"
          ],
          "operations": [
            {
              "operation": "READ",
              "trigger": "Load TLS material used by the etcd client",
              "conditions": [
                "Only when the corresponding TLS paths are configured"
              ],
              "implementation": "util.NewTLSConfig(util.WithCAPath(cacert), util.WithCertAndKeyPath(cert, key))"
            }
          ]
        }
      },
      "services": []
    },
    "MetaServerLifecycle.BuildStorage": {
      "infrastructure": {
        "etcd": {
          "conditions": [
            "Always while constructing memDB storage"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Create the etcd client used to seed and watch keyspace metadata",
              "conditions": [
                "Always during storage.NewMemDBStorage(cfg)"
              ],
              "implementation": "clientv3.New(clientv3.Config{Endpoints: cfg.Endpoints, TLS: cfg.TLSConfig, ...})"
            },
            {
              "operation": "STATUS",
              "trigger": "Validate the first etcd endpoint before continuing startup",
              "conditions": [
                "Always after the etcd client is created"
              ],
              "implementation": "etcdCli.Status(ctx, cfg.Endpoints[0])"
            }
          ]
        },
        "mysql": {
          "conditions": [
            "cfg.RdsSecretArn, cfg.CloudProviderType, and cfg.Region are all non-empty"
          ],
          "operations": [
            {
              "operation": "CONNECT",
              "trigger": "Connect the optional infra MySQL client used for cluster metadata sync",
              "conditions": [
                "Only when regional RDS settings are fully configured"
              ],
              "implementation": "connectDB(cfg) -> util.GetRdsConfig(...); gormutil.Connect(*connCfg)"
            }
          ]
        }
      },
      "services": []
    },
    "MetaServerLifecycle.StartStorage": {
      "infrastructure": {
        "etcd": {
          "conditions": [
            "Storage construction succeeded"
          ],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Read the PD cluster ID and all keyspace metadata into the in-memory store",
              "conditions": [
                "Always during the initial storage warmup"
              ],
              "implementation": "m.setKeyspaceMetaPrefix(ctx); m.fetchAllKeyspace(ctx)"
            }
          ]
        },
        "mysql": {
          "conditions": [
            "m.mysqlDB != nil and m.clusterMemDB != nil"
          ],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Load the current cluster rows and latest cluster events into the in-memory cluster cache",
              "conditions": [
                "Only when infra MySQL support is configured"
              ],
              "implementation": "m.loadAllClusterData(ctx)"
            }
          ]
        }
      },
      "services": []
    },
    "MetaServerLifecycle.StartupHTTP": {
      "infrastructure": {
        "http_server": {
          "conditions": [
            "StartStorage completed successfully"
          ],
          "operations": [
            {
              "operation": "LISTEN_AND_SERVE",
              "trigger": "Bind the TCP listener and start the HTTP server",
              "conditions": [
                "Always after registerHandlers(s)"
              ],
              "implementation": "net.Listen(\"tcp\", s.cfg.ServerAddr); http.Serve(ln, s.mux)"
            }
          ]
        }
      },
      "services": []
    },
    "MetaAPI.LookupKeyspace": {
      "infrastructure": {},
      "services": []
    },
    "MetaAPI.ListKeyspaces": {
      "infrastructure": {},
      "services": []
    },
    "MetaAPI.LookupCluster": {
      "infrastructure": {},
      "services": []
    },
    "MetaAPI.ListClusterEvents": {
      "infrastructure": {},
      "services": []
    },
    "MetaAPI.LookupKeyspaceV2": {
      "infrastructure": {},
      "services": []
    },
    "MetaAPI.ListKeyspacesV2": {
      "infrastructure": {},
      "services": []
    },
    "MetaStoreWatcher.WatchKeyspaceChanges": {
      "infrastructure": {
        "etcd": {
          "conditions": [
            "StartStorage completed successfully"
          ],
          "operations": [
            {
              "operation": "WATCH",
              "trigger": "Continuously watch keyspace metadata changes and update the in-memory keyspace table",
              "conditions": [
                "Always after the initial keyspace warmup"
              ],
              "implementation": "m.etcdCli.Watch(ctx, m.keyspaceMetaPrefix, clientv3.WithPrefix(), clientv3.WithRev(m.initRevision), clientv3.WithProgressNotify())"
            }
          ]
        }
      },
      "services": []
    },
    "MetaStoreWatcher.WatchClusterChanges": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "m.mysqlDB != nil and m.clusterMemDB != nil"
          ],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Poll cluster events and refresh the in-memory cluster cache from infra MySQL",
              "conditions": [
                "Every syncClustersInterval while the process is running"
              ],
              "implementation": "m.syncClusterChanges(ctx) -> tx.Where(\"event_id IN (?)\", eventSubQuery).Find(&events); clusterQuery.Find(&clustersToUpdate)"
            }
          ]
        }
      },
      "services": []
    }
  }
}
