Documentation ¶
Index ¶
- Variables
- func NewReader(receiver func() ([]byte, error)) io.Reader
- func NewSyncWriter(m *sync.Mutex, sender func(p []byte) error) io.Writer
- func NewWriter(sender func(p []byte) error) io.Writer
- func Proxy(revSend func() error) (err error)
- func ProxyFast(requestFunc func() error, requestStream CloseSender, responseFunc func() error) error
- func ProxyLoop(requestFunc func() error, requestStream CloseSender, responseFunc func() error) error
- type ChunkData
- type Chunker
- type CloseSender
- type Sender
Constants ¶
This section is empty.
Variables ¶
var WriteBufferSize = 128 * 1024
WriteBufferSize is the largest []byte that Write() will pass to its underlying send function.
Functions ¶
func NewReader ¶
NewReader turns receiver into an io.Reader. Errors from the receiver function are passed on unmodified. This means receiver should emit io.EOF when done.
func NewSyncWriter ¶
NewSyncWriter turns sender into an io.Writer. The sender callback will receive []byte arguments of length at most WriteBufferSize. All calls to the sender will be synchronized via the mutex.
func NewWriter ¶
NewWriter turns sender into an io.Writer. The sender callback will receive []byte arguments of length at most WriteBufferSize.
func Proxy ¶
Proxy calls recvSend until it receives an error. The error is returned to the caller unless it is io.EOF.
func ProxyFast ¶
func ProxyFast(requestFunc func() error, requestStream CloseSender, responseFunc func() error) error
ProxyFast works like Proxy but runs multiple callbacks simultaneously. It returns immediately if proxying one of the callbacks fails. If the response stream is done, ProxyBidi returns immediately without waiting for the client stream to finish proxying.
Types ¶
type Chunker ¶
type Chunker struct {
// contains filtered or unexported fields
}
Chunker lets you spread items you want to send over multiple chunks. This type is not thread-safe.
type CloseSender ¶
type CloseSender interface {
CloseSend() error
}
CloseSender captures the CloseSend method from gRPC streams.
type Sender ¶
type Sender interface { // Reset should create a fresh response message. Reset() // Append should append the given item to the slice in the current response message Append(ChunkData) // Send should send the current response message Send() error }
Sender encapsulates a gRPC response stream and the current chunk that's being built.
Reset, Append, [Append...], Send, Reset, Append, [Append...], Send, ...