Documentation ¶
Index ¶
- Constants
- type BasicAuth
- type CDCRESTClient
- type CDCRESTInterface
- type Config
- type HTTPMethod
- type Request
- func (r *Request) Do(ctx context.Context) (res *Result)
- func (r *Request) URL() *url.URL
- func (r *Request) WithBackoffBaseDelay(delay time.Duration) *Request
- func (r *Request) WithBackoffMaxDelay(delay time.Duration) *Request
- func (r *Request) WithBody(obj interface{}) *Request
- func (r *Request) WithHeader(key string, values ...string) *Request
- func (r *Request) WithMaxRetries(maxRetries uint64) *Request
- func (r *Request) WithMethod(method HTTPMethod) *Request
- func (r *Request) WithParam(name, value string) *Request
- func (r *Request) WithPrefix(segments ...string) *Request
- func (r *Request) WithTimeout(d time.Duration) *Request
- func (r *Request) WithURI(uri string) *Request
- type Result
Constants ¶
const ( HTTPMethodPost = iota + 1 HTTPMethodPut HTTPMethodGet HTTPMethodDelete )
Valid HTTP methods.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CDCRESTClient ¶
type CDCRESTClient struct { // Client is a wrapped http client. Client *httputil.Client // contains filtered or unexported fields }
CDCRESTClient defines a TiCDC RESTful client
func CDCRESTClientFromConfig ¶
func CDCRESTClientFromConfig(config *Config) (*CDCRESTClient, error)
CDCRESTClientFromConfig creates a CDCRESTClient from specific config items.
func NewCDCRESTClient ¶
func NewCDCRESTClient( baseURL *url.URL, versionedAPIPath string, client *httputil.Client, basicAuth BasicAuth, params url.Values, ) (*CDCRESTClient, error)
NewCDCRESTClient creates a new CDCRESTClient.
func (*CDCRESTClient) Delete ¶
func (c *CDCRESTClient) Delete() *Request
Delete begins a DELETE request. Short for c.Method(HTTPMethodDelete).
func (*CDCRESTClient) Get ¶
func (c *CDCRESTClient) Get() *Request
Get begins a GET request. Short for c.Method(HTTPMethodGet).
func (*CDCRESTClient) Method ¶
func (c *CDCRESTClient) Method(method HTTPMethod) *Request
Method begins a request with a http method (GET, POST, PUT, DELETE).
func (*CDCRESTClient) Post ¶
func (c *CDCRESTClient) Post() *Request
Post begins a POST request. Short for c.Method(HTTPMethodPost).
func (*CDCRESTClient) Put ¶
func (c *CDCRESTClient) Put() *Request
Put begins a PUT request. Short for c.Method(HTTPMethodPut).
type CDCRESTInterface ¶
type CDCRESTInterface interface { Method(method HTTPMethod) *Request Post() *Request Put() *Request Get() *Request Delete() *Request }
CDCRESTInterface includes a set of operations to interact with TiCDC RESTful apis.
type Config ¶
type Config struct { // Host must be a host string, a host:port pair, or a URL to the base of the cdc server. Host string // APIPath is a sub-path that points to an API root. APIPath string // Credential holds the security Credential used for generating tls config. Credential *security.Credential // API verion Version string // Extra query parameters Values url.Values // contains filtered or unexported fields }
Config holds the common attributes that can be passed to a cdc REST client
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request allows for building up a request to cdc server in a chained fasion. Any errors are stored until the end of your call, so you only have to check once.
func (*Request) WithBackoffBaseDelay ¶
WithBackoffBaseDelay specifies the base backoff sleep duration.
func (*Request) WithBackoffMaxDelay ¶
WithBackoffMaxDelay specifies the maximum backoff sleep duration.
func (*Request) WithBody ¶
WithBody makes http request use obj as its body. only supports two types now:
- io.Reader
- type which can be json marshalled
func (*Request) WithHeader ¶
WithHeader set the http request header.
func (*Request) WithMaxRetries ¶
WithMaxRetries specifies the maximum times a request will retry.
func (*Request) WithMethod ¶
func (r *Request) WithMethod(method HTTPMethod) *Request
WithMethod sets the method this request will use.
func (*Request) WithPrefix ¶
WithPrefix adds segments to the beginning of request url.
func (*Request) WithTimeout ¶
WithTimeout specifies overall timeout of a request.