Documentation
¶
Overview ¶
Package streamjoin gives response bodies whose bytes are produced incrementally to a reader that cannot report completion while the producer that writes them is still running.
A Lambda invocation ends when the handler has returned its response and the adapter has stopped consuming the response body. A producer goroutine that is still running at that point outlives the invocation that started it: it keeps holding the execution environment, and it can resume half-finished work on a later invocation of the same environment. Every incremental body therefore hands its producer to this package, which joins the producer on both exit paths of the body reader:
- the reader reaches EOF only after the producer has returned, so an adapter that drains a body to completion cannot return early;
- closing the reader unblocks the producer (by closing the pipe and canceling the producer context) and then waits for it to return, so an adapter that abandons a body also leaves no producer behind.
A producer that blocks on something this package cannot unblock — a read from a source that is neither closed nor canceled by the caller — keeps the documented io.Closer contract instead: Close unblocks blocked reads and writes. Producers must observe their context for the close path to be prompt.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Body ¶
type Body struct {
// contains filtered or unexported fields
}
Body is a response body backed by a producer goroutine. It implements io.ReadCloser and joins the producer on EOF and on Close.
func New ¶
New starts produce on its own goroutine and returns the body that streams its output.
The context handed to produce is canceled when the body is closed or when parent is done, so a producer that blocks on a channel receive can also be unblocked by Close.