ing-bank / scruid

Scala + Druid: Scruid. A library that allows you to compose queries in Scala, and parse the result back into typesafe classes.
Apache License 2.0
115 stars 29 forks source link

Scruid improvements [Breaking] #9

Closed bjgbeelen closed 6 years ago

bjgbeelen commented 6 years ago

This MR contains three changes:

Removing the type parameter of DruidQuery

The reason to do this is because it makes it easier to run parallel Druid Queries. We could now do someting like:

val future1 = TopNQuery(...).execute
val future2 = TopNQuery(...).execute
val future3 = TimeSeriesQuery(...).execute

val total: Future[List[DruidResponse]] = Future.sequence(List(future1, future2, future3))

This way we're not bitten by type erasures which would otherwise leaves us with a Future[Any] or something similarily obscure.

Introducing Circe Next, we introduce circe for the json decoding and encoding. Circe is supposed to be faster (according to the benchmakrs at https://github.com/circe/circe-benchmarks. Also, I noticed that Json4s out of the box marshalled all public properties in an object, not just the constructor properties. In the logs I encountered quite some fields in the json that should not belong to Druid query input.

Low level http client This MR now uses an Akka stream connectionFlow which gives better performance. The old Http.singleRequest method regularly gave pool overflow errors (https://doc.akka.io/docs/akka-http/current/client-side/pool-overflow.html). Test run locally seem this issue occurs now way less often

Fokko commented 6 years ago

Futrue? ;-)