Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterFlags ¶ added in v0.15.0
RegisterFlags registers the tabletconn flags on a given flagset. It is exported for tests that need to inject a particular TabletManagerProtocol.
func RegisterTabletManagerClientFactory ¶
func RegisterTabletManagerClientFactory(name string, factory TabletManagerClientFactory)
RegisterTabletManagerClientFactory allows modules to register TabletManagerClient implementations. Should be called on init().
Types ¶
type TabletManagerClient ¶
type TabletManagerClient interface { // Ping will try to ping the remote tablet Ping(ctx context.Context, tablet *topodatapb.Tablet) error // GetSchema asks the remote tablet for its database schema GetSchema(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.GetSchemaRequest) (*tabletmanagerdatapb.SchemaDefinition, error) // GetPermissions asks the remote tablet for its permissions list GetPermissions(ctx context.Context, tablet *topodatapb.Tablet) (*tabletmanagerdatapb.Permissions, error) // GetGlobalStatusVars returns the server's global status variables asked for. // An empty/nil variable name parameter slice means you want all of them. GetGlobalStatusVars(ctx context.Context, tablet *topodatapb.Tablet, variables []string) (map[string]string, error) // ResetSequences asks the remote tablet to reset the sequences for the specified tables ResetSequences(ctx context.Context, tablet *topodatapb.Tablet, tables []string) error // SetReadOnly makes the mysql instance read-only SetReadOnly(ctx context.Context, tablet *topodatapb.Tablet) error // SetReadWrite makes the mysql instance read-write SetReadWrite(ctx context.Context, tablet *topodatapb.Tablet) error // ChangeTags asks the remote tablet to change its tags ChangeTags(ctx context.Context, tablet *topodatapb.Tablet, tabletTags map[string]string, replace bool) (*tabletmanagerdatapb.ChangeTagsResponse, error) // ChangeType asks the remote tablet to change its type ChangeType(ctx context.Context, tablet *topodatapb.Tablet, dbType topodatapb.TabletType, semiSync bool) error // Sleep will sleep for a duration (used for tests) Sleep(ctx context.Context, tablet *topodatapb.Tablet, duration time.Duration) error // ExecuteHook executes the provided hook remotely ExecuteHook(ctx context.Context, tablet *topodatapb.Tablet, hk *hook.Hook) (*hook.HookResult, error) // RefreshState asks the remote tablet to reload its tablet record RefreshState(ctx context.Context, tablet *topodatapb.Tablet) error // RunHealthCheck asks the remote tablet to run a health check cycle RunHealthCheck(ctx context.Context, tablet *topodatapb.Tablet) error // ReloadSchema asks the remote tablet to reload its schema ReloadSchema(ctx context.Context, tablet *topodatapb.Tablet, waitPosition string) error // PreflightSchema will test a list of schema changes. PreflightSchema(ctx context.Context, tablet *topodatapb.Tablet, changes []string) ([]*tabletmanagerdatapb.SchemaChangeResult, error) // ApplySchema will apply a schema change ApplySchema(ctx context.Context, tablet *topodatapb.Tablet, change *tmutils.SchemaChange) (*tabletmanagerdatapb.SchemaChangeResult, error) LockTables(ctx context.Context, tablet *topodatapb.Tablet) error UnlockTables(ctx context.Context, tablet *topodatapb.Tablet) error // ExecuteQuery executes a query remotely on the tablet. // req.DbName is ignored in favor of using the tablet's DbName field, and, // if req.CallerId is nil, the effective callerid will be extracted from // the context. ExecuteQuery(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ExecuteQueryRequest) (*querypb.QueryResult, error) // ExecuteFetchAsDba executes a query remotely using the DBA pool. // req.DbName is ignored in favor of using the tablet's DbName field. // If usePool is set, a connection pool may be used to make the // query faster. Close() should close the pool in that case. ExecuteFetchAsDba(ctx context.Context, tablet *topodatapb.Tablet, usePool bool, req *tabletmanagerdatapb.ExecuteFetchAsDbaRequest) (*querypb.QueryResult, error) // ExecuteFetchAsDba executes multiple queries remotely using the DBA pool. // req.DbName is ignored in favor of using the tablet's DbName field. // If usePool is set, a connection pool may be used to make the // query faster. Close() should close the pool in that case. ExecuteMultiFetchAsDba(ctx context.Context, tablet *topodatapb.Tablet, usePool bool, req *tabletmanagerdatapb.ExecuteMultiFetchAsDbaRequest) ([]*querypb.QueryResult, error) // ExecuteFetchAsAllPrivs executes a query remotely using the allprivs user. // req.DbName is ignored in favor of using the tablet's DbName field. ExecuteFetchAsAllPrivs(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.ExecuteFetchAsAllPrivsRequest) (*querypb.QueryResult, error) // ExecuteFetchAsApp executes a query remotely using the App pool // If usePool is set, a connection pool may be used to make the // query faster. Close() should close the pool in that case. ExecuteFetchAsApp(ctx context.Context, tablet *topodatapb.Tablet, usePool bool, req *tabletmanagerdatapb.ExecuteFetchAsAppRequest) (*querypb.QueryResult, error) // GetUnresolvedTransactions returns the list of unresolved transactions for the tablet. GetUnresolvedTransactions(ctx context.Context, tablet *topodatapb.Tablet) ([]*querypb.TransactionMetadata, error) // ReadTransaction returns the metadata for the specified distributed transaction ID. ReadTransaction(ctx context.Context, tablet *topodatapb.Tablet, dtid string) (*querypb.TransactionMetadata, error) // ConcludeTransaction conclude the transaction on the tablet. ConcludeTransaction(ctx context.Context, tablet *topodatapb.Tablet, dtid string, mm bool) error // MysqlHostMetrics returns mysql system metrics MysqlHostMetrics(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.MysqlHostMetricsRequest) (*tabletmanagerdatapb.MysqlHostMetricsResponse, error) // PrimaryStatus returns the tablet's mysql primary status. PrimaryStatus(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) // ReplicationStatus returns the tablet's mysql replication status. ReplicationStatus(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.Status, error) // FullStatus returns the tablet's mysql replication status. FullStatus(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.FullStatus, error) // StopReplication stops the mysql replication StopReplication(ctx context.Context, tablet *topodatapb.Tablet) error // StopReplicationMinimum stops the mysql replication after it reaches // the provided minimum point StopReplicationMinimum(ctx context.Context, tablet *topodatapb.Tablet, stopPos string, waitTime time.Duration) (string, error) // StartReplication starts the mysql replication StartReplication(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) error // StartReplicationUntilAfter starts replication until after the position specified StartReplicationUntilAfter(ctx context.Context, tablet *topodatapb.Tablet, position string, duration time.Duration) error // GetReplicas returns the addresses of the replicas GetReplicas(ctx context.Context, tablet *topodatapb.Tablet) ([]string, error) // PrimaryPosition returns the tablet's primary position PrimaryPosition(ctx context.Context, tablet *topodatapb.Tablet) (string, error) // WaitForPosition waits for the position to be reached WaitForPosition(ctx context.Context, tablet *topodatapb.Tablet, pos string) error CreateVReplicationWorkflow(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.CreateVReplicationWorkflowRequest) (*tabletmanagerdatapb.CreateVReplicationWorkflowResponse, error) DeleteVReplicationWorkflow(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.DeleteVReplicationWorkflowRequest) (*tabletmanagerdatapb.DeleteVReplicationWorkflowResponse, error) HasVReplicationWorkflows(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.HasVReplicationWorkflowsRequest) (*tabletmanagerdatapb.HasVReplicationWorkflowsResponse, error) ReadVReplicationWorkflows(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.ReadVReplicationWorkflowsRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowsResponse, error) ReadVReplicationWorkflow(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.ReadVReplicationWorkflowRequest) (*tabletmanagerdatapb.ReadVReplicationWorkflowResponse, error) UpdateVReplicationWorkflow(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.UpdateVReplicationWorkflowRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowResponse, error) UpdateVReplicationWorkflows(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.UpdateVReplicationWorkflowsRequest) (*tabletmanagerdatapb.UpdateVReplicationWorkflowsResponse, error) ValidateVReplicationPermissions(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.ValidateVReplicationPermissionsRequest) (*tabletmanagerdatapb.ValidateVReplicationPermissionsResponse, error) // VReplicationExec executes a VReplication command VReplicationExec(ctx context.Context, tablet *topodatapb.Tablet, query string) (*querypb.QueryResult, error) VReplicationWaitForPos(ctx context.Context, tablet *topodatapb.Tablet, id int32, pos string) error VDiff(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.VDiffRequest) (*tabletmanagerdatapb.VDiffResponse, error) // ResetReplication tells a tablet to completely reset its // replication. All binary and relay logs are flushed. All // replication positions are reset. ResetReplication(ctx context.Context, tablet *topodatapb.Tablet) error // InitPrimary tells a tablet to make itself the new primary, // and return the replication position the replicas should use to // reparent to it. InitPrimary(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) (string, error) // PopulateReparentJournal asks the primary to insert a row in // its reparent_journal table. PopulateReparentJournal(ctx context.Context, tablet *topodatapb.Tablet, timeCreatedNS int64, actionName string, tabletAlias *topodatapb.TabletAlias, pos string) error // ReadReparentJournalInfo reads the information from reparent journal ReadReparentJournalInfo(ctx context.Context, tablet *topodatapb.Tablet) (int, error) // InitReplica tells a tablet to start replicating from the // passed in primary tablet alias, and wait for the row in the // reparent_journal table. InitReplica(ctx context.Context, tablet *topodatapb.Tablet, parent *topodatapb.TabletAlias, replicationPosition string, timeCreatedNS int64, semiSync bool) error // DemotePrimary tells the soon-to-be-former primary it's going to change, // and it should go read-only and return its current position. DemotePrimary(ctx context.Context, tablet *topodatapb.Tablet) (*replicationdatapb.PrimaryStatus, error) // UndoDemotePrimary reverts all changes made by DemotePrimary // To be used if we are unable to promote the chosen new primary UndoDemotePrimary(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) error // ReplicaWasPromoted tells the remote tablet it is now the primary ReplicaWasPromoted(ctx context.Context, tablet *topodatapb.Tablet) error // ResetReplicationParameters resets the replica replication parameters ResetReplicationParameters(ctx context.Context, tablet *topodatapb.Tablet) error // SetReplicationSource tells a tablet to start replicating from the // passed in tablet alias, and wait for the row in the // reparent_journal table (if timeCreatedNS is non-zero). SetReplicationSource(ctx context.Context, tablet *topodatapb.Tablet, parent *topodatapb.TabletAlias, timeCreatedNS int64, waitPosition string, forceStartReplication bool, semiSync bool, heartbeatInterval float64) error // ReplicaWasRestarted tells the replica tablet its primary has changed ReplicaWasRestarted(ctx context.Context, tablet *topodatapb.Tablet, parent *topodatapb.TabletAlias) error // StopReplicationAndGetStatus stops replication and returns the // current position. StopReplicationAndGetStatus(ctx context.Context, tablet *topodatapb.Tablet, stopReplicationMode replicationdatapb.StopReplicationMode) (*replicationdatapb.StopReplicationStatus, error) // PromoteReplica makes the tablet the new primary PromoteReplica(ctx context.Context, tablet *topodatapb.Tablet, semiSync bool) (string, error) // Backup creates a database backup Backup(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.BackupRequest) (logutil.EventStream, error) // RestoreFromBackup deletes local data and restores database from backup RestoreFromBackup(ctx context.Context, tablet *topodatapb.Tablet, req *tabletmanagerdatapb.RestoreFromBackupRequest) (logutil.EventStream, error) // Throttler CheckThrottler(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.CheckThrottlerRequest) (*tabletmanagerdatapb.CheckThrottlerResponse, error) GetThrottlerStatus(ctx context.Context, tablet *topodatapb.Tablet, request *tabletmanagerdatapb.GetThrottlerStatusRequest) (*tabletmanagerdatapb.GetThrottlerStatusResponse, error) // Close will be called when this TabletManagerClient won't be // used any more. It can be used to free any resource. Close() }
TabletManagerClient defines the interface used to talk to a remote tablet
func NewTabletManagerClient ¶
func NewTabletManagerClient() TabletManagerClient
NewTabletManagerClient creates a new TabletManagerClient. Should be called after flags are parsed.
type TabletManagerClientFactory ¶
type TabletManagerClientFactory func() TabletManagerClient
TabletManagerClientFactory is the factory method to create TabletManagerClient objects.
Click to show internal directories.
Click to hide internal directories.