Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpRequestTo ¶
DumpRequestTo is httputil.DumpRequest with some modifications. It will dump the request to the provided io.Writer with the body always, consuming the body in the process.
TODO we should support h2!
func IsStreamable ¶
IsStreamable says whether the given protocol can be used for streaming into hot functions.
Types ¶
type CallInfo ¶
type CallInfo interface { CallID() string ContentType() string Input() io.Reader // ProtocolType let's function/fdk's know what type original request is. Only 'http' for now. // This could be abstracted into separate Protocol objects for each type and all the following information could go in there. // This is a bit confusing because we also have the protocol's for getting information in and out of the function containers. ProtocolType() string Request() *http.Request RequestURL() string Headers() map[string][]string }
CallInfo is passed into dispatch with only the required data the protocols require
type CallRequestHTTP ¶
type CallRequestHTTP struct { Type string `json:"type"` RequestURL string `json:"request_url"` Headers http.Header `json:"headers"` }
CallRequestHTTP for the protocol that was used by the end user to call this function. We only have HTTP right now.
type CallResponseHTTP ¶
type CallResponseHTTP struct { StatusCode int `json:"status_code,omitempty"` Headers http.Header `json:"headers,omitempty"` }
CallResponseHTTP for the protocol that was used by the end user to call this function. We only have HTTP right now.
type ContainerIO ¶
type ContainerIO interface { IsStreamable() bool // Dispatch will handle sending stdin and stdout to a container. Implementers // of Dispatch may format the input and output differently. Dispatch must respect // the req.Context() timeout / cancellation. Dispatch(ctx context.Context, ci CallInfo, w io.Writer) error }
ContainerIO defines the interface used to talk to a hot function. Internally, a protocol must know when to alternate between stdin and stdout. It returns any protocol error, if present.
type DefaultProtocol ¶
type DefaultProtocol struct{}
DefaultProtocol is the protocol used by cold-containers
func (*DefaultProtocol) IsStreamable ¶
func (p *DefaultProtocol) IsStreamable() bool
type HTTPProtocol ¶
type HTTPProtocol struct {
// contains filtered or unexported fields
}
HTTPProtocol converts stdin/stdout streams into HTTP/1.1 compliant communication. It relies on Content-Length to know when to stop reading from containers stdout. It also mandates valid HTTP headers back and forth, thus returning errors in case of parsing problems.
func (*HTTPProtocol) Dispatch ¶
this is just an http.Handler really TODO handle req.Context better with io.Copy. io.Copy could push us over the timeout. TODO maybe we should take io.Writer, io.Reader but then we have to dump the request to a buffer again :(
func (*HTTPProtocol) IsStreamable ¶
func (p *HTTPProtocol) IsStreamable() bool
type JSONProtocol ¶
type JSONProtocol struct {
// contains filtered or unexported fields
}
JSONProtocol converts stdin/stdout streams from HTTP into JSON format.
func (*JSONProtocol) IsStreamable ¶
func (p *JSONProtocol) IsStreamable() bool
type Protocol ¶
type Protocol string
Protocol defines all protocols that operates a ContainerIO.
const ( Default Protocol = models.FormatDefault HTTP Protocol = models.FormatHTTP JSON Protocol = models.FormatJSON Empty Protocol = "" )
hot function protocols