MCPcopy Index your code
hub / github.com/coder/coder / getEncoder

Method getEncoder

coderd/cachecompress/compress.go:364–380  ·  view source on GitHub ↗

getEncoder returns a writer that encodes and writes to the provided writer, and a cleanup func.

(name string, w io.Writer)

Source from the content-addressed store, hash-verified

362
363// getEncoder returns a writer that encodes and writes to the provided writer, and a cleanup func.
364func (c *Compressor) getEncoder(name string, w io.Writer) (io.WriteCloser, func()) {
365 if pool, ok := c.pooledEncoders[name]; ok {
366 encoder, typeOK := pool.Get().(ioResetterWriter)
367 if !typeOK {
368 return nil, nil
369 }
370 cleanup := func() {
371 pool.Put(encoder)
372 }
373 encoder.Reset(w)
374 return encoder, cleanup
375 }
376 if fn, ok := c.encoders[name]; ok {
377 return fn(w, c.level), func() {}
378 }
379 return nil, nil
380}
381
382func matchAcceptEncoding(accepted []string, encoding string) bool {
383 for _, v := range accepted {

Callers 1

compressMethod · 0.95

Calls 2

GetMethod · 0.65
ResetMethod · 0.65

Tested by

no test coverage detected