Liking cljdoc? Tell your friends :D
Clojure only.

protojure.grpc.codec.compression


builtin-codecsclj

A map of built-in compression codecs, keyed by name.

NameDescription
"gzip"gzip codec
"deflate"deflate codec
"snappy"snappy codec

These built-in codecs are used by default, unless the caller overrides the codec dictionary. A common use case would be to augment the built-in codecs with 1 or more custom codecs.

Custom codecs

Map specification

The codec map consists of a collection of name/value pairs of codec-specifications keyed by a string representing the name of the codec.

["mycodec" {:input inputfn :output outputfn}]

where

  • inputfn: a (fn) that accepts an InputStream input, and returns an InputStream
  • outputfn: a (fn) that accepts an OutputStream input, and returns an OutputStream
Example
(assoc builtin-codecs
       "mycodec" {:input clojure.core/identity :output clojure.core/identity})

N.B.: The output stream returned in outputfn will have its (.close) method invoked to finalize compression. Therefore, the use of identity above would be problematic in the real-world since we may not wish to actually close the underlying stream at that time. Therefore, its use above is only for simplistic demonstration. A functional "pass through" example could be built using something like CloseShieldOutputStream

A map of built-in compression [codecs](https://en.wikipedia.org/wiki/Codec), keyed by name.

| Name         | Description                                            |
|--------------|--------------------------------------------------------|
| "gzip"     | [gzip](https://en.wikipedia.org/wiki/Gzip) codec       |
| "deflate"  | [deflate](https://en.wikipedia.org/wiki/DEFLATE) codec |
| "snappy"   | [snappy](https://github.com/google/snappy) codec       |

These built-in codecs are used by default, unless the caller overrides the codec dictionary.  A common use
case would be to augment the built-in codecs with 1 or more custom codecs.

#### Custom codecs

##### Map specification
The codec map consists of a collection of name/value pairs of codec-specifications keyed by a string representing
the name of the codec.

```
["mycodec" {:input inputfn :output outputfn}]
```

where

- **inputfn**: a (fn) that accepts an InputStream input, and returns an InputStream
- **outputfn**: a (fn) that accepts an OutputStream input, and returns an OutputStream

##### Example

```
(assoc builtin-codecs
       "mycodec" {:input clojure.core/identity :output clojure.core/identity})
```

**N.B.**: The output stream returned in _outputfn_ will have its (.close) method invoked to finalize
compression.  Therefore, the use of `identity` above would be problematic in the real-world since we
may not wish to actually close the underlying stream at that time.  Therefore, its use above is only for
simplistic demonstration.  A functional "pass through" example could be built using something like
[CloseShieldOutputStream](https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/output/CloseShieldOutputStream.html)
  
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close