Documentation ¶
Index ¶
- type API
- type JSONResponse
- func ApplySchema(ctx context.Context, r Request, api *API) *JSONResponse
- func CancelSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
- func CleanupSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
- func CompleteSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
- func CreateKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
- func CreateShard(ctx context.Context, r Request, api *API) *JSONResponse
- func DeleteKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
- func DeleteShards(ctx context.Context, r Request, api *API) *JSONResponse
- func DeleteTablet(ctx context.Context, r Request, api *API) *JSONResponse
- func EmergencyFailoverShard(ctx context.Context, r Request, api *API) *JSONResponse
- func FindSchema(ctx context.Context, r Request, api *API) *JSONResponse
- func GetBackups(ctx context.Context, r Request, api *API) *JSONResponse
- func GetCellInfos(ctx context.Context, r Request, api *API) *JSONResponse
- func GetCellsAliases(ctx context.Context, r Request, api *API) *JSONResponse
- func GetClusters(ctx context.Context, r Request, api *API) *JSONResponse
- func GetFullStatus(ctx context.Context, r Request, api *API) *JSONResponse
- func GetGates(ctx context.Context, r Request, api *API) *JSONResponse
- func GetKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
- func GetKeyspaces(ctx context.Context, r Request, api *API) *JSONResponse
- func GetSchema(ctx context.Context, r Request, api *API) *JSONResponse
- func GetSchemaMigrations(ctx context.Context, r Request, api *API) *JSONResponse
- func GetSchemas(ctx context.Context, r Request, api *API) *JSONResponse
- func GetShardReplicationPositions(ctx context.Context, r Request, api *API) *JSONResponse
- func GetSrvKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
- func GetSrvKeyspaces(ctx context.Context, r Request, api *API) *JSONResponse
- func GetSrvVSchema(ctx context.Context, r Request, api *API) *JSONResponse
- func GetSrvVSchemas(ctx context.Context, r Request, api *API) *JSONResponse
- func GetTablet(ctx context.Context, r Request, api *API) *JSONResponse
- func GetTablets(ctx context.Context, r Request, api *API) *JSONResponse
- func GetTopologyPath(ctx context.Context, r Request, api *API) *JSONResponse
- func GetVSchema(ctx context.Context, r Request, api *API) *JSONResponse
- func GetVSchemas(ctx context.Context, r Request, api *API) *JSONResponse
- func GetVtctlds(ctx context.Context, r Request, api *API) *JSONResponse
- func GetWorkflow(ctx context.Context, r Request, api *API) *JSONResponse
- func GetWorkflows(ctx context.Context, r Request, api *API) *JSONResponse
- func LaunchSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
- func NewJSONResponse(value any, err error) *JSONResponse
- func PingTablet(ctx context.Context, r Request, api *API) *JSONResponse
- func PlannedFailoverShard(ctx context.Context, r Request, api *API) *JSONResponse
- func RebuildKeyspaceGraph(ctx context.Context, r Request, api *API) *JSONResponse
- func RefreshState(ctx context.Context, r Request, api *API) *JSONResponse
- func RefreshTabletReplicationSource(ctx context.Context, r Request, api *API) *JSONResponse
- func ReloadSchemaShard(ctx context.Context, r Request, api *API) *JSONResponse
- func ReloadSchemas(ctx context.Context, r Request, api *API) *JSONResponse
- func ReloadTabletSchema(ctx context.Context, r Request, api *API) *JSONResponse
- func RemoveKeyspaceCell(ctx context.Context, r Request, api *API) *JSONResponse
- func RetrySchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
- func RunHealthCheck(ctx context.Context, r Request, api *API) *JSONResponse
- func SetReadOnly(ctx context.Context, r Request, api *API) *JSONResponse
- func SetReadWrite(ctx context.Context, r Request, api *API) *JSONResponse
- func StartReplication(ctx context.Context, r Request, api *API) *JSONResponse
- func StopReplication(ctx context.Context, r Request, api *API) *JSONResponse
- func TabletExternallyPromoted(ctx context.Context, r Request, api *API) *JSONResponse
- func VTExplain(ctx context.Context, r Request, api *API) *JSONResponse
- func Validate(ctx context.Context, r Request, api *API) *JSONResponse
- func ValidateKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
- func ValidateSchemaKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
- func ValidateShard(ctx context.Context, r Request, api *API) *JSONResponse
- func ValidateVersionKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
- func ValidateVersionShard(ctx context.Context, r Request, api *API) *JSONResponse
- type Options
- type Request
- type VTAdminHandler
- type Vars
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is used to power HTTP endpoint wrappers to the VTAdminServer interface.
func NewAPI ¶
func NewAPI(server vtadminpb.VTAdminServer, opts Options) *API
NewAPI returns an HTTP API backed by the given VTAdminServer implementation.
func (*API) Adapt ¶
func (api *API) Adapt(handler VTAdminHandler) http.HandlerFunc
Adapt converts a VTAdminHandler into an http.HandlerFunc. It deals with wrapping the request in a wrapper for some convenience functions and starts a new context, after extracting any potential spans that were set by an upstream middleware in the request context.
func (*API) Options ¶ added in v0.11.0
Options returns a copy of the Options this API was configured with.
func (*API) Server ¶ added in v0.11.0
func (api *API) Server() vtadminpb.VTAdminServer
Server returns the VTAdminServer wrapped by this API.
type JSONResponse ¶
type JSONResponse struct { Result any `json:"result,omitempty"` Error *errorBody `json:"error,omitempty"` Ok bool `json:"ok"` // contains filtered or unexported fields }
JSONResponse represents a generic response object.
func ApplySchema ¶ added in v0.19.0
func ApplySchema(ctx context.Context, r Request, api *API) *JSONResponse
ApplySchema implements the http wrapper for POST /migration/{cluster_id}/{keyspace}/.
func CancelSchemaMigration ¶ added in v0.19.0
func CancelSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
CancelSchemaMigration implements the http wrapper for /migration/{cluster_id}/{keyspace}/cancel[?uuid].
func CleanupSchemaMigration ¶ added in v0.19.0
func CleanupSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
CleanupSchemaMigration implements the http wrapper for /migration/{cluster_id}/{keyspace}/cleanup[?uuid].
func CompleteSchemaMigration ¶ added in v0.19.0
func CompleteSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
CompleteSchemaMigration implements the http wrapper for /migration/{cluster_id}/{keyspace}/complete[?uuid].
func CreateKeyspace ¶ added in v0.12.0
func CreateKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
CreateKeyspace implements the http wrapper for POST /keyspace/{cluster_id}.
func CreateShard ¶ added in v0.13.0
func CreateShard(ctx context.Context, r Request, api *API) *JSONResponse
CreateShard implements the http wrapper for POST /shards/{cluster_id}.
func DeleteKeyspace ¶ added in v0.12.0
func DeleteKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
DeleteKeyspace implements the http wrapper for DELETE /keyspace/{cluster_id}/{name}[?recursive=].
func DeleteShards ¶ added in v0.13.0
func DeleteShards(ctx context.Context, r Request, api *API) *JSONResponse
DeleteShards implements the http wrapper for DELETE /shards/{cluster_id}. Query params: - keyspace_shard: required, repeated list of keyspace/shards to delete. - recursive: bool - even_if_serving: bool
func DeleteTablet ¶ added in v0.13.0
func DeleteTablet(ctx context.Context, r Request, api *API) *JSONResponse
func EmergencyFailoverShard ¶ added in v0.14.0
func EmergencyFailoverShard(ctx context.Context, r Request, api *API) *JSONResponse
EmergencyFailoverShard implements the http wrapper for POST /shard/{cluster_id}/{keyspace}/{shard}/emergency_failover.
Query params: none
POST body is unmarshalled as vtctldatapb.EmergencyReparentShardRequest, but the Keyspace and Shard fields are ignored (coming instead from the route).
func FindSchema ¶ added in v0.10.0
func FindSchema(ctx context.Context, r Request, api *API) *JSONResponse
FindSchema implements the http wrapper for the /schema/{table}[?cluster_id=[&cluster_id=]] route.
func GetBackups ¶ added in v0.11.0
func GetBackups(ctx context.Context, r Request, api *API) *JSONResponse
GetBackups implements the http wrapper for /backups[?cluster_id=[&cluster_id=]].
func GetCellInfos ¶ added in v0.14.0
func GetCellInfos(ctx context.Context, r Request, api *API) *JSONResponse
GetCellInfos implements the http wrapper for the /cells[?cluster=[&cluster_id=...]?cell=[&cell=...]&names_only=(true|false)] route.
func GetCellsAliases ¶ added in v0.14.0
func GetCellsAliases(ctx context.Context, r Request, api *API) *JSONResponse
GetCellsAliases implements the http wrapper for the /cells_aliases[?cluster_id=[&cluster_id=]] route.
func GetClusters ¶ added in v0.10.0
func GetClusters(ctx context.Context, r Request, api *API) *JSONResponse
GetClusters implements the http wrapper for /clusters
func GetFullStatus ¶ added in v0.15.0
func GetFullStatus(ctx context.Context, r Request, api *API) *JSONResponse
GetFullStatus implements the http wrapper for /tablets/{tablet}/full_status
func GetGates ¶
func GetGates(ctx context.Context, r Request, api *API) *JSONResponse
GetGates implements the http wrapper for /gates[?cluster_id=[&cluster_id=]].
func GetKeyspace ¶ added in v0.11.0
func GetKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
GetKeyspace implements the http wrapper for /keyspace/{cluster_id}/{name}.
func GetKeyspaces ¶ added in v0.10.0
func GetKeyspaces(ctx context.Context, r Request, api *API) *JSONResponse
GetKeyspaces implements the http wrapper for /keyspaces[?cluster_id=[&cluster_id=]].
func GetSchema ¶ added in v0.10.0
func GetSchema(ctx context.Context, r Request, api *API) *JSONResponse
GetSchema implements the http wrapper for the /schema/{cluster_id}/{keyspace}/{table} route.
func GetSchemaMigrations ¶ added in v0.19.0
func GetSchemaMigrations(ctx context.Context, r Request, api *API) *JSONResponse
GetSchemaMigrations implements the http wrapper for /migrations/.
func GetSchemas ¶ added in v0.10.0
func GetSchemas(ctx context.Context, r Request, api *API) *JSONResponse
GetSchemas implements the http wrapper for the /schemas[?cluster_id=[&cluster_id=] route.
func GetShardReplicationPositions ¶ added in v0.12.0
func GetShardReplicationPositions(ctx context.Context, r Request, api *API) *JSONResponse
GetShardReplicationPositions implements the http wrapper for /shard_replication_positions. Query params:
- cluster_id: repeated, cluster ID
- keyspace: repeated, keyspace names
- keyspace_shard: repeated, keyspace shard names
func GetSrvKeyspace ¶ added in v0.17.0
func GetSrvKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
GetSrvKeyspace implements the http wrapper for the /api/srvkeyspaces/{cluster_id}/{name} route.
func GetSrvKeyspaces ¶ added in v0.17.0
func GetSrvKeyspaces(ctx context.Context, r Request, api *API) *JSONResponse
GetSrvKeyspaces implements the http wrapper for the /api/srvkeyspaces route.
func GetSrvVSchema ¶ added in v0.11.0
func GetSrvVSchema(ctx context.Context, r Request, api *API) *JSONResponse
GetSrvVSchema implements the http wrapper for the /api/srvvschema/{cluster_id}/{cell} route.
func GetSrvVSchemas ¶ added in v0.11.0
func GetSrvVSchemas(ctx context.Context, r Request, api *API) *JSONResponse
GetSrvVSchemas implements the http wrapper for the /api/srvvschemas route.
func GetTablet ¶
func GetTablet(ctx context.Context, r Request, api *API) *JSONResponse
GetTablet implements the http wrapper for /tablet/{tablet}[?cluster=[&cluster=]].
func GetTablets ¶
func GetTablets(ctx context.Context, r Request, api *API) *JSONResponse
GetTablets implements the http wrapper for /tablets[?cluster=[&cluster=]].
func GetTopologyPath ¶ added in v0.15.0
func GetTopologyPath(ctx context.Context, r Request, api *API) *JSONResponse
GetTopologyPath implements the http wrapper for /cluster/{cluster_id}/topology
Query params: - path: string
func GetVSchema ¶ added in v0.10.0
func GetVSchema(ctx context.Context, r Request, api *API) *JSONResponse
GetVSchema implements the http wrapper for the /vschema/{cluster_id}/{keyspace} route.
func GetVSchemas ¶ added in v0.10.0
func GetVSchemas(ctx context.Context, r Request, api *API) *JSONResponse
GetVSchemas implements the http wrapper for the /vschemas[?cluster_id=[&cluster_id=]] route.
func GetVtctlds ¶ added in v0.12.0
func GetVtctlds(ctx context.Context, r Request, api *API) *JSONResponse
GetVtctlds implements the http wrapper for /vtctlds[?cluster_id=[&cluster_id=]].
func GetWorkflow ¶ added in v0.10.0
func GetWorkflow(ctx context.Context, r Request, api *API) *JSONResponse
GetWorkflow implements the http wrapper for the VTAdminServer.GetWorkflow method.
Its route is /workflow/{cluster_id}/{keyspace}/{name}[?active_only=].
func GetWorkflows ¶ added in v0.10.0
func GetWorkflows(ctx context.Context, r Request, api *API) *JSONResponse
GetWorkflows implements the http wrapper for the VTAdminServer.GetWorkflows method.
Its route is /workflows, with query params: - cluster_id: repeated, cluster IDs - active_only - keyspace: repeated - ignore_keyspace: repeated
func LaunchSchemaMigration ¶ added in v0.19.0
func LaunchSchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
LaunchSchemaMigration implements the http wrapper for /migration/{cluster_id}/{keyspace}/launch[?uuid].
func NewJSONResponse ¶
func NewJSONResponse(value any, err error) *JSONResponse
NewJSONResponse returns a JSONResponse for the given result and error. If err is non-nil, and implements errors.TypedError, the HTTP status code and message are provided by the error. If not, the code and message fallback to 500 unknown.
func PingTablet ¶ added in v0.13.0
func PingTablet(ctx context.Context, r Request, api *API) *JSONResponse
PingTablet checks that the specified tablet is awake and responding to RPCs. This command can be blocked by other in-flight operations.
func PlannedFailoverShard ¶ added in v0.14.0
func PlannedFailoverShard(ctx context.Context, r Request, api *API) *JSONResponse
PlannedFailoverShard implements the http wrapper for POST /shard/{cluster_id}/{keyspace}/{shard}/planned_failover.
Query params: none
POST body is unmarshalled as vtctldatapb.PlannedReparentShardRequest, but the Keyspace and Shard fields are ignored (coming instead from the route).
func RebuildKeyspaceGraph ¶ added in v0.15.0
func RebuildKeyspaceGraph(ctx context.Context, r Request, api *API) *JSONResponse
RebuildKeyspaceGraph implements the http wrapper for /keyspaces/{cluster_id}/{name}/rebuild_keyspace_graph
func RefreshState ¶ added in v0.13.0
func RefreshState(ctx context.Context, r Request, api *API) *JSONResponse
RefreshState reloads the tablet record on the specified tablet.
func RefreshTabletReplicationSource ¶ added in v0.14.0
func RefreshTabletReplicationSource(ctx context.Context, r Request, api *API) *JSONResponse
RefreshTabletReplicationSource implements the http wrapper for PUT /tablet/{tablet}/refresh_replication_source.
Query params:
- cluster_id: repeatable, list of cluster IDs to restrict to when searching fo a tablet with that alias.
PUT body is unused; this endpoint takes no additional options.
func ReloadSchemaShard ¶ added in v0.15.0
func ReloadSchemaShard(ctx context.Context, r Request, api *API) *JSONResponse
ReloadSchemaShard implements the http wrapper for PUT /shard/{cluster_id}/{keyspace}/{shard}/reload_schema_shard
Query params: none
Body params: - wait_position: string - include_primary: bool - concurrency: uint32
func ReloadSchemas ¶ added in v0.14.0
func ReloadSchemas(ctx context.Context, r Request, api *API) *JSONResponse
ReloadSchemas implements the http wrapper for /schemas/reload
func ReloadTabletSchema ¶ added in v0.14.0
func ReloadTabletSchema(ctx context.Context, r Request, api *API) *JSONResponse
ReloadTabletSchema implements the http wrapper for /tablets/{tablet}/reload_schema.
Note that all query parameters that apply to ReloadSchemas, except for `cluster_id`, are ignored.
func RemoveKeyspaceCell ¶ added in v0.15.0
func RemoveKeyspaceCell(ctx context.Context, r Request, api *API) *JSONResponse
RemoveKeyspaceCell implements the http wrapper for /keyspaces/{cluster_id}/{name}/remove_keyspace_cell
func RetrySchemaMigration ¶ added in v0.19.0
func RetrySchemaMigration(ctx context.Context, r Request, api *API) *JSONResponse
RetrySchemaMigration implements the http wrapper for /migration/{cluster_id}/{keyspace}/retry[?uuid].
func RunHealthCheck ¶ added in v0.13.0
func RunHealthCheck(ctx context.Context, r Request, api *API) *JSONResponse
RunHealthCheck runs a healthcheck on the tablet and returns the result.
func SetReadOnly ¶ added in v0.14.0
func SetReadOnly(ctx context.Context, r Request, api *API) *JSONResponse
SetReadOnly sets the tablet to read only mode
func SetReadWrite ¶ added in v0.14.0
func SetReadWrite(ctx context.Context, r Request, api *API) *JSONResponse
SetReadWrite sets the tablet to read write mode
func StartReplication ¶ added in v0.13.0
func StartReplication(ctx context.Context, r Request, api *API) *JSONResponse
StartReplication starts replication on the specified tablet.
func StopReplication ¶ added in v0.13.0
func StopReplication(ctx context.Context, r Request, api *API) *JSONResponse
StopReplication stops replication on the specified tablet.
func TabletExternallyPromoted ¶ added in v0.14.0
func TabletExternallyPromoted(ctx context.Context, r Request, api *API) *JSONResponse
TabletExternallyPromoted implements the http wrapper for POST /tablet/{tablet}/tablet_externally_promoted.
Query params: - `cluster_id`: repeated list of clusterIDs to limit the request to.
POST body is unused; this endpoint takes no additional options.
func VTExplain ¶ added in v0.10.0
func VTExplain(ctx context.Context, r Request, api *API) *JSONResponse
VTExplain implements the http wrapper for /vtexplain?cluster_id=&keyspace=&sql=
func Validate ¶ added in v0.15.0
func Validate(ctx context.Context, r Request, api *API) *JSONResponse
Validate implements the http wrapper for /cluster/{cluster_id}/validate
func ValidateKeyspace ¶ added in v0.14.0
func ValidateKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
ValidateKeyspace validates that all nodes reachable from the specified keyspace are consistent.
func ValidateSchemaKeyspace ¶ added in v0.14.0
func ValidateSchemaKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
ValidateSchemaKeyspace validates that all nodes reachable from the specified keyspace are consistent.
func ValidateShard ¶ added in v0.15.0
func ValidateShard(ctx context.Context, r Request, api *API) *JSONResponse
ValidateShard implements the http wrapper for PUT /shard/{cluster_id}/{keyspace}/{shard}/validate
Query params: none
Body params: - ping_tablets: bool
func ValidateVersionKeyspace ¶ added in v0.14.0
func ValidateVersionKeyspace(ctx context.Context, r Request, api *API) *JSONResponse
ValidateVersionKeyspace validates that the version on the primary of shard 0 matches all of the other tablets in the keyspace.
func ValidateVersionShard ¶ added in v0.15.0
func ValidateVersionShard(ctx context.Context, r Request, api *API) *JSONResponse
ValidateVersionShard implements the http wrapper for PUT /shard/{cluster_id}/{keyspace}/{shard}/validate_version
Query params: none
Body params: none
func (*JSONResponse) WithHTTPStatus ¶
func (r *JSONResponse) WithHTTPStatus(code int) *JSONResponse
WithHTTPStatus forces a response to be used for the JSONResponse.
func (*JSONResponse) Write ¶
func (r *JSONResponse) Write(w http.ResponseWriter)
Write marshals a JSONResponse into the http response.
type Options ¶
type Options struct { // CORSOrigins is the list of origins to allow via CORS. An empty or nil // slice disables CORS entirely. CORSOrigins []string // EnableTracing specifies whether to install a tracing middleware on the // API subrouter. EnableTracing bool // DisableCompression specifies whether to turn off gzip compression for API // endpoints. It is named as the negative (as opposed to EnableTracing) so // the zero value has compression enabled. DisableCompression bool // DisableDebug specifies whether to omit the /debug/pprof/* and /debug/env // routes. DisableDebug bool ExperimentalOptions struct { TabletURLTmpl string } }
Options defines the set of configurations for an HTTP API server.
type Request ¶
Request wraps an *http.Request to provide some convenience functions for accessing request data.
func (Request) ParseQueryParamAsBool ¶ added in v0.10.0
ParseQueryParamAsBool attempts to parse the query parameter of the given name into a boolean value. If the parameter is not set, the provided default value is returned.
func (Request) ParseQueryParamAsInt32 ¶ added in v0.19.0
ParseQueryParamAsInt32 attempts to parse the query parameter of the given name into a uint32 value. If the parameter is not set, the provided default value is returned.
func (Request) ParseQueryParamAsUint32 ¶ added in v0.11.0
ParseQueryParamAsUint32 attempts to parse the query parameter of the given name into a uint32 value. If the parameter is not set, the provided default value is returned.
type VTAdminHandler ¶
type VTAdminHandler func(ctx context.Context, r Request, api *API) *JSONResponse
VTAdminHandler is an HTTP endpoint handler that takes, via injection, everything needed to implement a JSON API response.
type Vars ¶ added in v0.14.0
Vars is a mapping of the route variable values in a given request.
See (gorilla/mux).Vars for details. We define a type here to add some additional behavior for extracting non-string values.
func (Vars) GetTabletAlias ¶ added in v0.14.0
func (v Vars) GetTabletAlias(key string) (*topodatapb.TabletAlias, error)
GetTabletAlias returns the route named `key` as a TabletAlias.
It returns an error if the route has no variable with that name, or if it cannot be parsed as a TabletAlias.