Skip to content

Commit

Permalink
Add http gzip compression
Browse files Browse the repository at this point in the history
Previously all the requests were delivered in plan bytes.
This adds ability to send compressed requests to the collector.
  • Loading branch information
peel committed Dec 5, 2023
1 parent b9000d1 commit f12b920
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Alternatively you can write events directly to a S3 bucket:
"output": {
"type": "Http"
"endpoint": "https://my.collector.endpoint.com"
"gzip": true
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object Config {
case class File(path: URI) extends Output
case class PubSub(subscription: String) extends Output
case class Kafka(brokers: String, topic: String, producerConf: Map[String, String] = Map.empty) extends Output
case class Http(endpoint: org.http4s.Uri) extends Output
case class Http(endpoint: org.http4s.Uri, gzip: Option[Boolean]) extends Output
}

val configOpt = Opts.option[Path]("config", "Path to the configuration HOCON").orNone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import cats.syntax.all._

import cats.effect.Async

import org.http4s.client.middleware.GZip
import org.http4s.ember.client.EmberClientBuilder
import org.http4s.Request
import org.http4s.Header.Raw
Expand Down Expand Up @@ -100,7 +101,8 @@ object Http {
return req
}

val httpClient = EmberClientBuilder.default[F].build
val emberClient = EmberClientBuilder.default[F].build
val httpClient = if (properties.gzip.getOrElse(false)) emberClient.map(GZip[F](32 * 1024)) else emberClient

st: Stream[F, Main.GenOutput] => {
Stream
Expand Down

0 comments on commit f12b920

Please sign in to comment.