Documentation
¶
Overview ¶
Provides a mechanism for writing data to a buffer and reading it later. The buffer is stored in a map of buffered pipes, which are removed after a certain amount of time. The output of a buffered pipe can be read by sending a GET request to a specific URL.
Index ¶
Constants ¶
const ( BufferedPipeMapTTL = 30 * time.Second // The time-to-live for a buffered pipe in the map of buffered pipes. BufferedPipeGetterUrl = "/api/buffered-pipe" // The URL for getting the output of a buffered pipe. )
Variables ¶
This section is empty.
Functions ¶
func HandleGetBufferedPipeOutput ¶
func HandleGetBufferedPipeOutput(w http.ResponseWriter, r *http.Request)
Handle a HTTP GET request to get the output of a buffered pipe, given a key.
func SetBufferedPipe ¶
func SetBufferedPipe(pipe *BufferedPipe)
Set a buffered pipe in the map of buffered pipes.
Types ¶
type BufferedPipe ¶
type BufferedPipe struct { Key string // a unique key for the pipe // contains filtered or unexported fields }
A pipe that allows for lazy writing to a downstream writer. Data written to the pipe is buffered until WriteTo is called.
func GetBufferedPipe ¶
func GetBufferedPipe(key string) (*BufferedPipe, bool)
Get a buffered pipe from the map of buffered pipes, given a key.
func NewBufferedPipe ¶
func NewBufferedPipe(timeout time.Duration) *BufferedPipe
Create a new BufferedPipe with a timeout. The writer will be closed after the timeout
func (*BufferedPipe) Close ¶
func (pipe *BufferedPipe) Close() error
Close the pipe. This will cause any blocking WriteTo calls to return.
func (*BufferedPipe) GetOutputUrl ¶
func (pipe *BufferedPipe) GetOutputUrl() (string, error)
Get the URL for reading the output of the pipe.
type BufferedPipeMap ¶
type BufferedPipeMap struct {
// contains filtered or unexported fields
}