Documentation
¶
Index ¶
- Constants
- func Compress(in mem.BufferSlice, compressor *CompressionPool, pool mem.BufferPool) (out mem.BufferSlice, isCompressed bool, err error)
- func Decompress(d mem.BufferSlice, maxReceiveMessageSize int, decompressor *CompressionPool, ...) (out mem.BufferSlice, isDecompressed bool, err error)
- func NegotiateCompression(availableCompressors ReadOnlyCompressionPools, sent, accept string) (requestCompression, responseCompression string, clientVisibleErr error)
- type CompressionPool
- type Compressor
- type Decompressor
- type ReadOnlyCompressionPools
Constants ¶
View Source
const ( CompressionGzip = "gzip" CompressionIdentity = "identity" )
Variables ¶
This section is empty.
Functions ¶
func Compress ¶
func Compress(in mem.BufferSlice, compressor *CompressionPool, pool mem.BufferPool) (out mem.BufferSlice, isCompressed bool, err error)
func Decompress ¶
func Decompress(d mem.BufferSlice, maxReceiveMessageSize int, decompressor *CompressionPool, pool mem.BufferPool) (out mem.BufferSlice, isDecompressed bool, err error)
func NegotiateCompression ¶
func NegotiateCompression( availableCompressors ReadOnlyCompressionPools, sent, accept string, ) (requestCompression, responseCompression string, clientVisibleErr error)
NegotiateCompression determines and validates the request compression and response compression using the available compressors and protocol-specific Content-Encoding and Accept-Encoding headers.
Types ¶
type CompressionPool ¶
type CompressionPool struct {
// contains filtered or unexported fields
}
func NewCompressionPool ¶
func NewCompressionPool(compressor Compressor, decompressor Decompressor) *CompressionPool
func (*CompressionPool) Compress ¶
func (c *CompressionPool) Compress(w io.Writer) (io.WriteCloser, error)
func (*CompressionPool) Decompress ¶
type Compressor ¶
type Compressor interface {
io.Writer
// Close flushes any buffered data to the underlying sink, then closes the
// Compressor. It must not close the underlying sink.
Close() error
// Reset discards the Compressor's internal state, if any, and prepares it to
// write compressed data to a new sink.
Reset(io.Writer)
}
A Compressor is a reusable wrapper that compresses data written to an underlying sink. The standard library's [*gzip.Writer] implements Compressor.
type Decompressor ¶
type Decompressor interface {
io.Reader
// Close closes the Decompressor, but not the underlying data source. It may
// return an error if the Decompressor wasn't read to EOF.
Close() error
// Reset discards the Decompressor's internal state, if any, and prepares it
// to read from a new source of compressed data.
Reset(io.Reader) error
}
A Decompressor is a reusable wrapper that decompresses an underlying data source. The standard library's [*gzip.Reader] implements Decompressor.
type ReadOnlyCompressionPools ¶
type ReadOnlyCompressionPools interface {
Get(string) *CompressionPool
Contains(string) bool
// Wordy, but clarifies how this is different from readOnlyCodecs.Names().
CommaSeparatedNames() string
}
ReadOnlyCompressionPools is a read-only interface to a map of named CompressionPools.
func NewReadOnlyCompressionPools ¶
func NewReadOnlyCompressionPools( nameToPool map[string]*CompressionPool, reversedNames []string, ) ReadOnlyCompressionPools
Click to show internal directories.
Click to hide internal directories.