Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
Deadline() strfmt.DateTime
CallType() string
// 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
Method() string
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"`
Method string `json:"method"`
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) 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