Documentation ¶
Index ¶
- Variables
- type APIDefinition
- type APIParamDefinition
- func APIParamDBName(name string, required bool) APIParamDefinition
- func APIParamEnum(name string, required bool, items []EnumItemDefinition) APIParamDefinition
- func APIParamInt(name string, required bool) APIParamDefinition
- func APIParamIntWithDefaultVal(name string, required bool, defVal string) APIParamDefinition
- func APIParamPDKey(name string, required bool) APIParamDefinition
- func APIParamTableID(name string, required bool) APIParamDefinition
- func APIParamTableName(name string, required bool) APIParamDefinition
- func APIParamText(name string, required bool) APIParamDefinition
- type APIParamResolveFn
- type EnumItemDefinition
- type HTTPClients
- type RequestPayload
- type RequestPayloadResolver
- type ResolvedRequestPayload
- type UIComponentDropdownProps
- type UIComponentTextProps
Constants ¶
This section is empty.
Variables ¶
var ( ErrNS = errorx.NewNamespace("debug_api.endpoint") ErrUnknownComponent = ErrNS.NewType("unknown_component") ErrInvalidEndpoint = ErrNS.NewType("invalid_endpoint") )
Functions ¶
This section is empty.
Types ¶
type APIDefinition ¶
type APIDefinition struct { ID string `json:"id"` Component topo.Kind `json:"component"` Path string `json:"path"` Method string `json:"method"` PathParams []APIParamDefinition `json:"path_params"` // e.g. /stats/dump/{db}/{table} -> db, table QueryParams []APIParamDefinition `json:"query_params"` // e.g. /debug/pprof?seconds=1 -> seconds BeforeSendRequest func(req *httpclient.LazyRequest) `json:"-"` }
APIDefinition defines what an API endpoints accepts. APIDefinition can be "resolved" to become a request when its parameter values are given via RequestPayload.
type APIParamDefinition ¶
type APIParamDefinition struct { Name string `json:"name"` Required bool `json:"required"` UIComponentKind string `json:"ui_kind"` UIComponentProps interface{} `json:"ui_props"` // varies by different ui kinds OnResolve APIParamResolveFn `json:"-"` }
APIParamDefinition defines what an API endpoint parameter accepts and how it should look like in the UI. Usually this struct doesn't need to be manually constructed. Use APIParamXxx() helpers.
func APIParamDBName ¶
func APIParamDBName(name string, required bool) APIParamDefinition
func APIParamEnum ¶
func APIParamEnum(name string, required bool, items []EnumItemDefinition) APIParamDefinition
func APIParamInt ¶
func APIParamInt(name string, required bool) APIParamDefinition
func APIParamIntWithDefaultVal ¶
func APIParamIntWithDefaultVal(name string, required bool, defVal string) APIParamDefinition
func APIParamPDKey ¶
func APIParamPDKey(name string, required bool) APIParamDefinition
func APIParamTableID ¶
func APIParamTableID(name string, required bool) APIParamDefinition
func APIParamTableName ¶
func APIParamTableName(name string, required bool) APIParamDefinition
func APIParamText ¶
func APIParamText(name string, required bool) APIParamDefinition
type APIParamResolveFn ¶
type EnumItemDefinition ¶
type HTTPClients ¶
type HTTPClients struct { PDAPIClient *pdclient.APIClient TiDBStatusClient *tidbclient.StatusClient TiKVStatusClient *tikvclient.StatusClient TiFlashStatusClient *tiflashclient.StatusClient TiCDCStatusClient *ticdcclient.StatusClient TiProxyStatusClient *tiproxyclient.StatusClient TSOStatusClient *tsoclient.StatusClient SchedulingStatusClient *schedulingclient.StatusClient }
func (HTTPClients) GetHTTPClientByNodeKind ¶
func (c HTTPClients) GetHTTPClientByNodeKind(kind topo.Kind) *httpclient.Client
type RequestPayload ¶
type RequestPayload struct { API string `json:"api_id"` Host string `json:"host"` Port int `json:"port"` ParamValues map[string]string `json:"param_values"` }
RequestPayload describes how a server-side request should be sent, by describing the API endpoint to send and its parameter values. The content of this struct is specified by the user so that it should be carefully checked.
type RequestPayloadResolver ¶
type RequestPayloadResolver struct {
// contains filtered or unexported fields
}
RequestPayloadResolver resolves the request payload using specified API definitions.
The relationship is below:
RequestPayload ---(RequestPayloadResolver.ResolvePayload)---> ResolvedRequestPayload
func NewRequestPayloadResolver ¶
func NewRequestPayloadResolver(apis []APIDefinition, acceptedClients HTTPClients) *RequestPayloadResolver
func (*RequestPayloadResolver) ListAPIs ¶
func (r *RequestPayloadResolver) ListAPIs() []APIDefinition
func (*RequestPayloadResolver) ResolvePayload ¶
func (r *RequestPayloadResolver) ResolvePayload(payload RequestPayload) (*ResolvedRequestPayload, error)
type ResolvedRequestPayload ¶
type ResolvedRequestPayload struct {
// contains filtered or unexported fields
}
ResolvedRequestPayload describes the final request to send by the server. It is constructed by from the RequestPayload and the corresponding APIDefinition.
func (*ResolvedRequestPayload) SendRequestAndPipe ¶
type UIComponentDropdownProps ¶
type UIComponentDropdownProps struct {
Items []EnumItemDefinition `json:"items"`
}
UIComponentDropdownProps is the type of UIComponentProps when UIComponentKind is "dropdown".
type UIComponentTextProps ¶
type UIComponentTextProps struct { Placeholder string `json:"placeholder"` DefaultVal string `json:"default_val"` }
UIComponentTextProps is the type of UIComponentProps when UIComponentKind is "text".