http

package
v0.12.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func (api *API) Options() Options

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 interface{} `json:"result,omitempty"`
	Error  *errorBody  `json:"error,omitempty"`
	Ok     bool        `json:"ok"`
	// contains filtered or unexported fields
}

JSONResponse represents a generic response object.

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 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 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=[&cluster=]] 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=[&cluster=]].

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 GetGates

func GetGates(ctx context.Context, r Request, api *API) *JSONResponse

GetGates implements the http wrapper for /gates[?cluster=[&cluster=]].

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=[&cluster=]].

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 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=[&cluster=] 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: repeated, cluster ID
  • keyspace: repeated, keyspace names
  • keyspace_shard: repeated, keyspace shard names

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 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=[&cluster=]] 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=[&cluster=]].

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: repeated, cluster IDs - active_only - keyspace: repeated - ignore_keyspace: repeated

func NewJSONResponse

func NewJSONResponse(value interface{}, 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 VTExplain added in v0.10.0

func VTExplain(ctx context.Context, r Request, api *API) *JSONResponse

VTExplain implements the http wrapper for /vtexplain?cluster=&keyspace=&sql=

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

type Request struct{ *http.Request }

Request wraps an *http.Request to provide some convenience functions for accessing request data.

func (Request) ParseQueryParamAsBool added in v0.10.0

func (r Request) ParseQueryParamAsBool(name string, defaultVal bool) (bool, error)

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) ParseQueryParamAsUint32 added in v0.11.0

func (r Request) ParseQueryParamAsUint32(name string, defaultVal uint32) (uint32, error)

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.

func (Request) Vars

func (r Request) Vars() map[string]string

Vars returns the route variables in a request, if any, as defined by gorilla/mux.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL