Documentation ¶
Index ¶
- type API
- type JSONResponse
- func FindSchema(ctx context.Context, r Request, api *API) *JSONResponse
- func GetClusters(ctx context.Context, r Request, api *API) *JSONResponse
- func GetGates(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 GetSchemas(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 GetVSchema(ctx context.Context, r Request, api *API) *JSONResponse
- func GetVSchemas(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 NewJSONResponse(value interface{}, err error) *JSONResponse
- func VTExplain(ctx context.Context, r Request, api *API) *JSONResponse
- type Options
- type Request
- type VTAdminHandler
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) *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.
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 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 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 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 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 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 }
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.
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.