PHAB_ID=DD334087
finatra-httpclient: introduce new HttpClientModuleTrait and deprecate HttpClientModule. The HttpClientModule has been modified to extend from HttpClientModuleTrait to allow for bridging the two implementations. c.t.f.httpclient.RichHttpClient has also been deprecated as part of this change. The new HttpClientModuleTrait allows for direct configuration of the underling c.t.finagle.Http.Client. The new HttpClientModuleTrait does not provide any default bindings, so it is up to users to supply them - this allows for custom binding annotations and binding multiple HttpClients, which was not previously possible with HttpClientModule. fe0c94aa
To migrate,
class MyHttpClientModule extends HttpClientModule {
override val dest = "flag!mydest"
override val sslHostname = Some("sslHost")
}
becomes
class MyHttpClientModule extends HttpClientModuleTrait {
override val dest = "flag!mydest"
override val label = "myhttpclient"
val sslHostname = "sslHost"
// we only override in this example for TLS configuration with the `sslHostname`
override def configureClient(
injector: Injector,
client: Http.Client
): Http.Client = client.withTls(sslHostname)
@Singleton
@Provides
final def provideHttpClient(
injector: Injector,
statsReceiver: StatsReceiver,
mapper: FinatraObjectMapper
): HttpClient = newHttpClient(injector, statsReceiver, mapper)
// Note that `provideHttpClient` no longer needs an injected `Service[Request, Response]` so
// the following is only needed if you require a `Service[Request, Response]` elsewhere:
@Singleton
@Provides
final def provideHttpService(
injector: Injector,
statsReceiver: StatsReceiver
): Service[Request, Response] = newService(injector, statsReceiver)
}
com.twitter.util.BypassScheduler
used
for speeding up ConstFuture.map
(transformTry
). Now, we always run map
operations immediately instead of via the Scheduler, where they may be queued
and potentially reordered. 64114324