Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) BuildRequest(m encoding.Marshaler, opt ...RequestOpt) (*http.Request, error)
- func (c *Client) Do(m encoding.Marshaler, opt ...RequestOpt) (res mesos.Response, err error)
- func (c *Client) Endpoint() string
- func (c *Client) HandleResponse(res *http.Response, err error) (mesos.Response, error)
- func (c *Client) Mesos(opts ...RequestOpt) mesos.Client
- func (c *Client) With(opts ...Opt) Opt
- func (c *Client) WithTemporary(opt Opt, f func() error) error
- type Config
- type ConfigOpt
- func BasicAuth(username, passwd string) ConfigOpt
- func RoundTripper(rt http.RoundTripper) ConfigOpt
- func TLSConfig(tc *tls.Config) ConfigOpt
- func Timeout(d time.Duration) ConfigOpt
- func Transport(modifyTransport func(*http.Transport)) ConfigOpt
- func WrapRoundTripper(f func(http.RoundTripper) http.RoundTripper) ConfigOpt
- type DoFunc
- type ErrorMapperFunc
- type HTTPRequestHelper
- type Opt
- type Opts
- type ProtocolError
- type RequestOpt
- type RequestOpts
- type Response
- type ResponseHandler
Constants ¶
This section is empty.
Variables ¶
var DefaultConfigOpt []ConfigOpt
DefaultConfigOpt represents the default client config options.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a Mesos HTTP APIs client.
func New ¶
New returns a new Client with the given Opts applied. Callers are expected to configure the URL, Do, and Codec options prior to invoking Do.
func (*Client) BuildRequest ¶
BuildRequest is a factory func that generates and returns an http.Request for the given marshaler and request options.
func (*Client) Do ¶
func (c *Client) Do(m encoding.Marshaler, opt ...RequestOpt) (res mesos.Response, err error)
Do sends a Call and returns (a) a Response (should be closed when finished) that contains a streaming Decoder from which callers can read Events from, and; (b) an error in case of failure. Callers are expected to *always* close a non-nil Response if one is returned. For operations which are successful but also for which there is no expected object stream as a result the embedded Decoder will be nil.
func (*Client) Endpoint ¶
URL returns the current Mesos API endpoint URL that the caller is set to invoke
func (*Client) HandleResponse ¶
HandleResponse parses an HTTP response from a Mesos service endpoint, transforming the raw HTTP response into a mesos.Response.
func (*Client) Mesos ¶
func (c *Client) Mesos(opts ...RequestOpt) mesos.Client
Mesos returns a mesos.Client variant backed by this implementation
type ConfigOpt ¶
type ConfigOpt func(*Config)
func BasicAuth ¶
BasicAuth generates a functional config option that sets HTTP Basic authentication for a Client
func RoundTripper ¶
func RoundTripper(rt http.RoundTripper) ConfigOpt
RoundTripper returns a ConfigOpt that sets a Config's round-tripper.
func Timeout ¶
Timeout returns an ConfigOpt that sets a Config's response header timeout, tls handshake timeout, and dialer timeout.
func Transport ¶
Transport returns a ConfigOpt that allows tweaks of the default Config's http.Transport
func WrapRoundTripper ¶
func WrapRoundTripper(f func(http.RoundTripper) http.RoundTripper) ConfigOpt
WrapRoundTripper allows a caller to customize a configuration's HTTP exchanger. Useful for authentication protocols that operate over stock HTTP.
type DoFunc ¶
DoFunc sends an HTTP request and returns an HTTP response.
An error is returned if caused by client policy (such as http.Client.CheckRedirect), or if there was an HTTP protocol error. A non-2xx response doesn't cause an error.
When err is nil, resp always contains a non-nil resp.Body.
Callers should close resp.Body when done reading from it. If resp.Body is not closed, an underlying RoundTripper (typically Transport) may not be able to re-use a persistent TCP connection to the server for a subsequent "keep-alive" request.
The request Body, if non-nil, will be closed by an underlying Transport, even on errors.
type ErrorMapperFunc ¶
ErrorMapperFunc generates an error for the given response.
type HTTPRequestHelper ¶
HTTPRequestHelper wraps an http.Request and provides utility funcs to simplify code elsewhere
type Opt ¶
Opt defines a functional option for the HTTP client type. A functional option must return an Opt that acts as an "undo" if applied to the same Client.
func DefaultHeader ¶
DefaultHeader returns an Opt that adds a header to an Client's headers.
func ErrorMapper ¶
func ErrorMapper(em ErrorMapperFunc) Opt
ErrorMapper returns am Opt that overrides the existing error mapping behavior of the client.
func HandleResponse ¶
func HandleResponse(f ResponseHandler) Opt
HandleResponse returns a functional config option to set the HTTP response handler of the client.
func RequestOptions ¶
func RequestOptions(opts ...RequestOpt) Opt
RequestOptions returns an Opt that applies the given set of options to every Client request.
type ProtocolError ¶
type ProtocolError string
ProtocolError is returned when we receive a response from Mesos that is outside of the HTTP API specification. Receipt of the following will yield protocol errors:
- any unexpected non-error HTTP response codes (e.g. 199)
- any unexpected Content-Type
func (ProtocolError) Error ¶
func (pe ProtocolError) Error() string
Error implements error interface
type RequestOpt ¶
RequestOpt defines a functional option for an http.Request.
func Close ¶
func Close(b bool) RequestOpt
Close returns a RequestOpt that determines whether to close the underlying connection after sending the request.
func Header ¶
func Header(k, v string) RequestOpt
Header returns an RequestOpt that adds a header value to an HTTP requests's header.
type RequestOpts ¶
type RequestOpts []RequestOpt
RequestOpts is a convenience type
func (RequestOpts) Apply ¶
func (opts RequestOpts) Apply(req *http.Request)
Apply this set of request options to the given HTTP request.