softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.44k stars 301 forks source link

Why `terminateActorSystemOnClose` ignored for `usingActorSystem` ctor? #391

Closed fsanaulla closed 4 years ago

fsanaulla commented 4 years ago

Hello, thank you for your great library!

Should this ctor ignore terminateActorSystemOnClose?

  def usingActorSystem(
      actorSystem: ActorSystem,
      options: SttpBackendOptions = SttpBackendOptions.Default,
      customHttpsContext: Option[HttpsConnectionContext] = None,
      customConnectionPoolSettings: Option[ConnectionPoolSettings] = None,
      customLog: Option[LoggingAdapter] = None,
      customizeRequest: HttpRequest => HttpRequest = identity,
      customizeWebsocketRequest: WebSocketRequest => WebSocketRequest = identity
  )(
      implicit ec: ExecutionContext = ExecutionContext.Implicits.global
  ): SttpBackend[Future, Source[ByteString, Any], Flow[Message, Message, *]] = {
    usingClient(
      actorSystem,
      options,
      customConnectionPoolSettings,
      AkkaHttpClient.default(actorSystem, customHttpsContext, customLog),
      customizeRequest,
      customizeWebsocketRequest
    )
  }
adamw commented 4 years ago

It's using the default value, terminateActorSystemOnClose = false.

That's because in this scenario, the actor system is externally managed, not by sttp. As it wasn't created by the sttp client, it's also not closed by the sttp client.

fsanaulla commented 4 years ago

@adamw Thank you!