{
  "repo": "tidbcloud/account",
  "binary": "worker",
  "binary_path": "central/cmd/worker/main.go",
  "dependencies": {
    "HealthService.Healthz": {
      "infrastructure": {},
      "services": []
    },
    "HealthService.Version": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get central DB version",
              "conditions": ["Always"],
              "implementation": "migrate.GetCentralDBVersion()"
            }
          ]
        }
      },
      "services": []
    },
    "HealthService.Metrics": {
      "infrastructure": {},
      "services": []
    },
    "JobQueueHandler.SyncSalesforce": {
      "infrastructure": {},
      "services": [
        {
          "name": "salesforce",
          "target_interface": "SyncLeads",
          "target_repo": "salesforce.com",
          "operation_type": "http_api",
          "conditions": ["EnableSalesforce == true"],
          "operations": [
            {
              "operation": "HTTP API SyncLeads",
              "trigger": "Sync leads to Salesforce",
              "conditions": ["EnableSalesforce == true"],
              "implementation": "salesforceClient.SyncLeads(ctx, lead)"
            }
          ]
        }
      ]
    },
    "JobQueueHandler.SyncZendesk": {
      "infrastructure": {},
      "services": [
        {
          "name": "zendesk",
          "target_interface": "CreateOrUpdateUser",
          "target_repo": "zendesk.com",
          "operation_type": "http_api",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "HTTP API CreateOrUpdateUser",
              "trigger": "Sync user to Zendesk",
              "conditions": ["Always"],
              "implementation": "zendeskClient.CreateOrUpdateUser(ctx, user)"
            }
          ]
        }
      ]
    },
    "JobQueueHandler.SyncPocApplication": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get POC application",
              "conditions": ["Always"],
              "implementation": "GetPocApplicationByID(ctx, pocApplicationID)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "salesforce",
          "target_interface": "SyncPocApplication",
          "target_repo": "salesforce.com",
          "operation_type": "http_api",
          "conditions": ["EnableSalesforce == true"],
          "operations": [
            {
              "operation": "HTTP API SyncPocApplication",
              "trigger": "Sync POC application to Salesforce",
              "conditions": ["EnableSalesforce == true"],
              "implementation": "salesforceClient.SyncPocApplication(ctx, pocApplication)"
            }
          ]
        }
      ]
    },
    "JobQueueHandler.HeartBeatSignal": {
      "infrastructure": {},
      "services": []
    },
    "ClusterEventHandler.ClusterCreating": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Check if user landing action exists",
              "conditions": ["OperatorID != 0"],
              "implementation": "userSvc.IsExist(ctx, clusterFilter)"
            },
            {
              "operation": "INSERT",
              "trigger": "Create user landing action for cluster creation",
              "conditions": ["Action not exists"],
              "implementation": "userSvc.SaveFirstAction(ctx, queryEntity, userLandingAction)"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterEventHandler.ClusterCreated": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "List org users by scope",
              "conditions": ["Always"],
              "implementation": "rbacUserSvc.ListUsersByScope(ctx, entity.RoleBindingScopeOrg, data.TenantID)"
            },
            {
              "operation": "SELECT",
              "trigger": "List project users by scope",
              "conditions": ["Always"],
              "implementation": "rbacUserSvc.ListUsersByScope(ctx, entity.RoleBindingScopeProject, data.ProjectID)"
            },
            {
              "operation": "INSERT",
              "trigger": "Batch create DB user cluster commands",
              "conditions": ["Project users found"],
              "implementation": "dbUserSrv.BatchCreateCommandDBUserCluster(ctx, objs)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "GetClusterById",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC GetClusterById",
              "trigger": "Get cluster info",
              "conditions": ["Always"],
              "implementation": "infra.GetHandler().GetClusterById(ctx, data.ClusterID, true)"
            }
          ]
        }
      ]
    },
    "ClusterEventHandler.ClusterLaunching": {
      "infrastructure": {
        "mysql": {
          "conditions": ["!IsDevTier"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "List org keys for tenant",
              "conditions": ["!IsDevTier"],
              "implementation": "dbUserSrv.ListOrgKeys(ctx, filter)"
            },
            {
              "operation": "INSERT",
              "trigger": "Create org key command if not exist",
              "conditions": ["!IsDevTier && No org keys"],
              "implementation": "dbUserSrv.CreateCommandOrgKeyIfNotExist(ctx, data.TenantID, ...)"
            },
            {
              "operation": "INSERT",
              "trigger": "Create cluster key command",
              "conditions": ["!IsDevTier"],
              "implementation": "dbUserSrv.CreateCommandClusterKey(ctx, data.TenantID, data.ClusterID, ...)"
            }
          ]
        }
      },
      "services": []
    },
    "ClusterEventHandler.ClusterDeleting": {
      "infrastructure": {},
      "services": [
        {
          "name": "redis",
          "target_interface": "Publish/Delete",
          "target_repo": "internal",
          "operation_type": "cache",
          "conditions": ["ClusterID != 0"],
          "operations": [
            {
              "operation": "DELETE cluster cache",
              "trigger": "Delete cluster from local cache",
              "conditions": ["Always"],
              "implementation": "infra.GetClusterCache(ctx).Delete(key)"
            },
            {
              "operation": "PUBLISH DeleteClusterCache",
              "trigger": "Notify other workers to delete cache",
              "conditions": ["Always"],
              "implementation": "redisClient.Publish(ctx, redisChanel, data.ClusterID)"
            }
          ]
        }
      ]
    },
    "ClusterEventHandler.ClusterDeleted": {
      "infrastructure": {},
      "services": [
        {
          "name": "redis",
          "target_interface": "Publish/Delete",
          "target_repo": "internal",
          "operation_type": "cache",
          "conditions": ["ClusterID != 0"],
          "operations": [
            {
              "operation": "DELETE cluster cache",
              "trigger": "Delete cluster from local cache",
              "conditions": ["Always"],
              "implementation": "infra.GetClusterCache(ctx).Delete(key)"
            },
            {
              "operation": "PUBLISH DeleteClusterCache",
              "trigger": "Notify other workers to delete cache",
              "conditions": ["Always"],
              "implementation": "redisClient.Publish(ctx, redisChanel, data.ClusterID)"
            }
          ]
        }
      ]
    },
    "OrgEventHandler.OrgActivate": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get org by ID",
              "conditions": ["Always"],
              "implementation": "orgSvc.GetOrgByID(ctx, data.OrgId)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "msp-service",
          "target_interface": "CustomerRegistrationNotice",
          "target_repo": "tidbcloud/account",
          "operation_type": "internal",
          "conditions": ["OrgEventType == Activate && OrgTag == MspCustomer"],
          "operations": [
            {
              "operation": "CustomerRegistrationNotice",
              "trigger": "Send MSP customer registration notice",
              "conditions": ["MSP customer activation"],
              "implementation": "mspSvc.CustomerRegistrationNotice(ctx, data.OrgId)"
            }
          ]
        }
      ]
    },
    "DataAppBindClusterEventHandler.AddApiKey": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get API key by ID",
              "conditions": ["Always"],
              "implementation": "apiKeySvc.GetApiKeyByID(ctx, apiKeyID)"
            },
            {
              "operation": "INSERT",
              "trigger": "Create DB user cluster command",
              "conditions": ["API key and cluster exist"],
              "implementation": "dbUserSrv.CreateCommandDBUserClusterWithTime(ctx, ...)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "GetClusterById",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC GetClusterById",
              "trigger": "Get cluster info for DB user creation",
              "conditions": ["Always"],
              "implementation": "infra.GetHandler().GetClusterById(ctx, clusterID, true)"
            }
          ]
        }
      ]
    },
    "DataAppBindClusterEventHandler.DelApiKey": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get API key by ID",
              "conditions": ["Always"],
              "implementation": "apiKeySvc.GetApiKeyByID(ctx, apiKeyID)"
            },
            {
              "operation": "INSERT",
              "trigger": "Create delete DB user cluster command",
              "conditions": ["API key and cluster exist"],
              "implementation": "dbUserSrv.CreateCommandDBUserClusterWithTime(ctx, ...)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "GetClusterById",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC GetClusterById",
              "trigger": "Get cluster info for DB user deletion",
              "conditions": ["Always"],
              "implementation": "infra.GetHandler().GetClusterById(ctx, clusterID, true)"
            }
          ]
        }
      ]
    },
    "DataAppBindClusterEventHandler.AddCluster": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get data app related API keys",
              "conditions": ["Always"],
              "implementation": "apiKeySvc.ListApiKeysByResourceID(ctx, &param)"
            },
            {
              "operation": "SELECT",
              "trigger": "Get API key by ID",
              "conditions": ["Always"],
              "implementation": "apiKeySvc.GetApiKeyByID(ctx, key.Id)"
            },
            {
              "operation": "INSERT",
              "trigger": "Create DB user cluster commands",
              "conditions": ["API keys found"],
              "implementation": "dbUserSrv.CreateCommandDBUserClusterWithTime(ctx, ...)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "GetClusterById",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC GetClusterById",
              "trigger": "Get cluster info",
              "conditions": ["Always"],
              "implementation": "infra.GetHandler().GetClusterById(ctx, clusterID, true)"
            }
          ]
        }
      ]
    },
    "DataAppBindClusterEventHandler.DelCluster": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get data app related API keys",
              "conditions": ["Always"],
              "implementation": "apiKeySvc.ListApiKeysByResourceID(ctx, &param)"
            },
            {
              "operation": "SELECT",
              "trigger": "Get API key by ID",
              "conditions": ["Always"],
              "implementation": "apiKeySvc.GetApiKeyByID(ctx, key.Id)"
            },
            {
              "operation": "INSERT",
              "trigger": "Create delete DB user cluster commands",
              "conditions": ["API keys found"],
              "implementation": "dbUserSrv.CreateCommandDBUserClusterWithTime(ctx, ...)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "GetClusterById",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC GetClusterById",
              "trigger": "Get cluster info",
              "conditions": ["Always"],
              "implementation": "infra.GetHandler().GetClusterById(ctx, clusterID, true)"
            }
          ]
        }
      ]
    },
    "RedisSubscriber.DeleteClusterCache": {
      "infrastructure": {},
      "services": [
        {
          "name": "redis",
          "target_interface": "Subscribe",
          "target_repo": "internal",
          "operation_type": "pubsub",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SUBSCRIBE DeleteClusterCache",
              "trigger": "Subscribe to cluster cache deletion channel",
              "conditions": ["Always"],
              "implementation": "redis.GetRedisClient().Subscribe(ctx, redisChanel)"
            },
            {
              "operation": "DELETE cluster cache",
              "trigger": "Delete cluster cache on message",
              "conditions": ["Message received"],
              "implementation": "infra.GetClusterCache(ctx).Delete(clusterId)"
            }
          ]
        }
      ]
    },
    "BackgroundWorkers.CleanupTenantWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get deleted tenants",
              "conditions": ["Always"],
              "implementation": "entity.NewTenantQuerySet(tx).StatusEq(entity.TenantStatusDeleted).All(&tenants)"
            },
            {
              "operation": "UPDATE",
              "trigger": "Update tenant status to cleared",
              "conditions": ["Resources cleaned"],
              "implementation": "org.UpdateTenantStatus(tx, t.ID, entity.TenantStatusCleared)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "CleanTenantResource",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Tenant deleted"],
          "operations": [
            {
              "operation": "gRPC CleanTenantResource",
              "trigger": "Clean tenant resources in CM",
              "conditions": ["Always"],
              "implementation": "infra.GetHandler().CleanTenantResource(ctx, t.ID.Uint64())"
            }
          ]
        }
      ]
    },
    "BackgroundWorkers.CleanupProjectWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get deleted projects",
              "conditions": ["Always"],
              "implementation": "entity.NewProjectQuerySet(tx).StatusEq(entity.ProjectStatusDeleted).All(&projects)"
            },
            {
              "operation": "UPDATE",
              "trigger": "Clear project",
              "conditions": ["No active clusters"],
              "implementation": "project.ClearProject(ctx, tx, p.ID)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "core-svc",
          "target_interface": "CoreService.ListClusters",
          "target_repo": "tidbcloud/core-svc",
          "operation_type": "grpc_unary",
          "conditions": ["Project deleted"],
          "operations": [
            {
              "operation": "gRPC CoreService.ListClusters",
              "trigger": "Check if project has active clusters",
              "conditions": ["Always"],
              "implementation": "infra.GetHandler().GetProjectClustersNotInStatus(ctx, p.ID.Uint64(), ...)"
            }
          ]
        },
        {
          "name": "infra-service",
          "target_interface": "CleanProjectResource",
          "target_repo": "tidbcloud/infra-service",
          "operation_type": "grpc_unary",
          "conditions": ["Project deleted"],
          "operations": [
            {
              "operation": "gRPC CleanProjectResource",
              "trigger": "Clean project resources",
              "conditions": ["No active clusters"],
              "implementation": "infra.GetHandler().CleanProjectResource(ctx, p.ID.Uint64())"
            }
          ]
        }
      ]
    },
    "BackgroundWorkers.PocApplicationWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get POC applications",
              "conditions": ["Always"],
              "implementation": "pocApplicationQuery"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.SyncTenantWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get tenants to sync",
              "conditions": ["Always"],
              "implementation": "tenantQuery"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.SQSMonitorWorker": {
      "infrastructure": {
        "sqs": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "GetQueueAttributes",
              "trigger": "Monitor SQS queue status",
              "conditions": ["Always"],
              "implementation": "sqs.GetQueueAttributes()"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.MarketplaceWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get tenant by account code",
              "conditions": ["Subscribe change detected"],
              "implementation": "entity.NewTenantQuerySet(tx).ThirdPartyAccountCodeEq(code).All(&tenants)"
            },
            {
              "operation": "UPDATE",
              "trigger": "Update tenant free trial status",
              "conditions": ["Subscribe status changed"],
              "implementation": "entity.NewTenantQuerySet(tx).IDEq(tenant.ID).GetUpdater().SetThirdPartyFreeTrial(...)"
            }
          ]
        },
        "redis": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "PUBLISH",
              "trigger": "Publish subscribe/unsubscribe event",
              "conditions": ["Status changed"],
              "implementation": "eventbus.Get().PublishEventWithTransaction(...)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "account-provider",
          "target_interface": "ProcessTenantSubscribeChange",
          "target_repo": "tidbcloud/account",
          "operation_type": "internal",
          "conditions": ["MarketPlaceConfig.EnableBackground"],
          "operations": [
            {
              "operation": "GetAllAccountProviders",
              "trigger": "Get all account providers",
              "conditions": ["Always"],
              "implementation": "handler.GetAccountHandler().GetAllAccountProviders()"
            },
            {
              "operation": "ProcessTenantSubscribeChange",
              "trigger": "Process subscribe changes for each provider",
              "conditions": ["Always"],
              "implementation": "provider.ProcessTenantSubscribeChange(ctx, w.ProcessSubscribeChange)"
            }
          ]
        },
        {
          "name": "billing-service",
          "target_interface": "GetMonthlyBills",
          "target_repo": "tidbcloud/billing2",
          "operation_type": "grpc_unary",
          "conditions": ["Unsubscribe detected"],
          "operations": [
            {
              "operation": "gRPC GetMonthlyBills",
              "trigger": "Get monthly bills for notification",
              "conditions": ["User unsubscribed"],
              "implementation": "billing2.GetHandler().GetMonthlyBills(ctx, tenantID, year, month)"
            }
          ]
        },
        {
          "name": "account-api",
          "target_interface": "SendEmail/SendEmailByLabels",
          "target_repo": "tidbcloud/account",
          "operation_type": "grpc_unary",
          "conditions": ["Unsubscribe detected"],
          "operations": [
            {
              "operation": "gRPC SendEmail",
              "trigger": "Send notification email to ops",
              "conditions": ["User unsubscribed"],
              "implementation": "w.accountAPI.SendEmail(ctx, &accountpb.SendEmailReq{...})"
            },
            {
              "operation": "gRPC SendEmailByLabels",
              "trigger": "Send unsubscribe email to customer",
              "conditions": ["User unsubscribed"],
              "implementation": "w.accountAPI.SendEmailByLabels(ctx, &accountpb.SendEmailByLabelsReq{...})"
            }
          ]
        }
      ]
    },
    "BackgroundWorkers.DBUserWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get waiting DB user commands",
              "conditions": ["Always"],
              "implementation": "commandDBUserClusterQuery"
            },
            {
              "operation": "UPDATE",
              "trigger": "Update command status",
              "conditions": ["Command processed"],
              "implementation": "updateCommandStatus"
            }
          ]
        },
        "dynamodb": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "GET/PUT",
              "trigger": "Check/create API key in DynamoDB",
              "conditions": ["API key operations"],
              "implementation": "dynamodbOperations"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "ExecuteSQL/CreateDBUser/DeleteDBUser",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC ExecuteSQL",
              "trigger": "Execute SQL for DB user operations",
              "conditions": ["Command ready"],
              "implementation": "cmClient.ExecuteSQL(ctx, sqlStatement)"
            }
          ]
        }
      ]
    },
    "BackgroundWorkers.DBUserCheckWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get DB users to check",
              "conditions": ["Always"],
              "implementation": "dbUserCheckQuery"
            }
          ]
        },
        "dynamodb": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "GET",
              "trigger": "Verify API key in DynamoDB",
              "conditions": ["API key check"],
              "implementation": "dynamodbGet"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "ListSqlUsers",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC ListSqlUsers",
              "trigger": "List SQL users from cluster for verification",
              "conditions": ["Always"],
              "implementation": "cmClient.ListSqlUsers(ctx, clusterId)"
            }
          ]
        }
      ]
    },
    "BackgroundWorkers.DynamoDBDataValidationWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get API keys and privilege roles from MySQL",
              "conditions": ["Always"],
              "implementation": "apiKeyQuery/privilegeRoleQuery"
            }
          ]
        },
        "dynamodb": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SCAN/GET",
              "trigger": "Get API keys and privilege roles from DynamoDB",
              "conditions": ["Always"],
              "implementation": "dynamodbScan/dynamodbGet"
            },
            {
              "operation": "PUT",
              "trigger": "Sync data to DynamoDB if inconsistent",
              "conditions": ["Data mismatch"],
              "implementation": "dynamodbPut"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.MspCustomerConvertWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get MSP customers to convert",
              "conditions": ["Always"],
              "implementation": "mspCustomerQuery"
            },
            {
              "operation": "UPDATE",
              "trigger": "Update MSP customer status",
              "conditions": ["Conversion complete"],
              "implementation": "updateMspCustomerStatus"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.MspClearUserServicesAgreementWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get user services agreements to clear",
              "conditions": ["Always"],
              "implementation": "userServicesAgreementQuery"
            },
            {
              "operation": "DELETE",
              "trigger": "Clear user services agreements",
              "conditions": ["Agreement expired"],
              "implementation": "deleteUserServicesAgreement"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.RoleBindingMonitorWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get role bindings to monitor",
              "conditions": ["Always"],
              "implementation": "roleBindingQuery"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.ClusterRelationMonitorWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get cluster relations to monitor",
              "conditions": ["Always"],
              "implementation": "clusterRelationQuery"
            }
          ]
        }
      },
      "services": []
    },
    "BackgroundWorkers.ClusterRelationSyncWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT/UPSERT",
              "trigger": "Sync cluster relations",
              "conditions": ["Always"],
              "implementation": "syncClusterRelations"
            }
          ]
        }
      },
      "services": [
        {
          "name": "cm-service",
          "target_interface": "SyncClusterRelations",
          "target_repo": "tidbcloud/cm-api",
          "operation_type": "grpc_unary",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "gRPC SyncClusterRelations",
              "trigger": "Sync cluster relations with CM",
              "conditions": ["Always"],
              "implementation": "cmClient.SyncClusterRelations(ctx, ...)"
            }
          ]
        }
      ]
    },
    "BackgroundWorkers.CleanupUserSessionWorker": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "DELETE",
              "trigger": "Delete expired user sessions",
              "conditions": ["Always"],
              "implementation": "deleteExpiredUserSessions"
            }
          ]
        }
      },
      "services": []
    }
  }
}
