Skip to content

Commit

Permalink
Merge pull request #230 from MAIF/issue-228
Browse files Browse the repository at this point in the history
Fix bug on client
  • Loading branch information
larousso authored Mar 13, 2019
2 parents 0566e19 + c0ca25a commit 26ccfd0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
9 changes: 5 additions & 4 deletions izanami-clients/jvm/build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import sbt.Keys.{organization, scalacOptions}
import sbtrelease.ReleaseStateTransformations._

val akkaVersion = "2.5.17"

val disabledPlugins = if (sys.env.get("TRAVIS_TAG").filterNot(_.isEmpty).isDefined) {
Seq(RevolverPlugin)
} else {
Seq(RevolverPlugin, BintrayPlugin)
}

val akkaVersion = "2.5.19"
val akkaHttpVersion = "10.1.7"

lazy val jvm = (project in file("."))
.disablePlugins(disabledPlugins: _*)
.settings(
Expand All @@ -18,12 +19,12 @@ lazy val jvm = (project in file("."))
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream" % akkaVersion,
"com.typesafe.akka" %% "akka-slf4j" % akkaVersion,
"com.typesafe.akka" %% "akka-http" % "10.1.3",
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
"com.lightbend.akka" %% "akka-stream-alpakka-sse" % "0.19",
"io.vavr" % "vavr" % "0.9.2",
"org.reactivecouchbase.json" % "json-lib" % "1.0.0",
"com.google.guava" % "guava" % "25.1-jre",
"com.typesafe.play" %% "play-json" % "2.6.9",
"com.typesafe.play" %% "play-json" % "2.7.0",
"com.chuusai" %% "shapeless" % "2.3.3",
"com.adelegue" %% "playjson-extended" % "0.0.4",
"junit" % "junit" % "4.12" % Test,
Expand Down
4 changes: 2 additions & 2 deletions izanami-clients/jvm/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ akka.http {
host-connection-pool {
# The maximum number of parallel connections that a connection pool to a
# single host endpoint is allowed to establish. Must be greater than zero.
max-connections = 4
max-connections = 128

# The minimum number of parallel connections that a pool should keep alive ("hot").
# If the number of connections is falling below the given threshold, new ones are being spawned.
Expand All @@ -38,7 +38,7 @@ akka.http {
# Note that with N concurrent materializations the max number of open request in the pool
# will never exceed N * max-connections * pipelining-limit.
# Must be a power of 2 and > 0!
max-open-requests = 32
max-open-requests = 128

# The maximum number of requests that are dispatched to the target host in
# batch-mode across a single connection (HTTP pipelining).
Expand Down
20 changes: 2 additions & 18 deletions izanami-clients/jvm/src/main/scala/izanami/commons/client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,9 @@ private[izanami] class HttpClient(system: ActorSystem, config: ClientConfig) {

private val uri = Uri(config.host)

private val http: Flow[(HttpRequest, Unit), (Try[HttpResponse], Unit), HostConnectionPool] = uri.scheme match {
case "https" =>
logger.info(s"Creating https connection pool for {}:{}", uri.authority.host.address(), uri.authority.port)
Http().cachedHostConnectionPoolHttps(uri.authority.host.address(), uri.authority.port)
case _ =>
logger.info(s"Creating http connection pool for {}:{}", uri.authority.host.address(), uri.authority.port)
Http().cachedHostConnectionPool(uri.authority.host.address(), uri.authority.port)
}
private val http = Http()

private def singleRequest(r: HttpRequest): Future[HttpResponse] =
Source
.single(r -> ())
.via(http)
.map(_._1)
.flatMapConcat {
case Success(s) => Source.single(s)
case Failure(e) => Source.failed(e)
}
.runWith(Sink.head)
private def singleRequest(r: HttpRequest): Future[HttpResponse] = http.singleRequest(r)

private val headers = (for {
clientId <- config.clientId
Expand Down

0 comments on commit 26ccfd0

Please sign in to comment.