mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-27 21:46:04 +02:00
![twitter-team](/assets/img/avatar_default.png)
Please note we have force-pushed a new initial commit in order to remove some publicly-available Twitter user information. Note that this process may be required in the future.
52 lines
1.7 KiB
Scala
52 lines
1.7 KiB
Scala
package com.twitter.home_mixer.module
|
|
|
|
import com.google.inject.Provides
|
|
import com.twitter.conversions.DurationOps._
|
|
import com.twitter.finagle.mtls.authentication.ServiceIdentifier
|
|
import com.twitter.finagle.thrift.ClientId
|
|
import com.twitter.finagle.thriftmux.MethodBuilder
|
|
import com.twitter.finatra.mtls.thriftmux.modules.MtlsClient
|
|
import com.twitter.inject.Injector
|
|
import com.twitter.inject.thrift.modules.ThriftMethodBuilderClientModule
|
|
import com.twitter.stitch.tweetypie.TweetyPie
|
|
import com.twitter.tweetypie.thriftscala.TweetService
|
|
import com.twitter.util.Duration
|
|
import javax.inject.Singleton
|
|
|
|
/**
|
|
* Idempotent TweetyPie Thrift and Stitch client.
|
|
*/
|
|
object TweetyPieClientModule
|
|
extends ThriftMethodBuilderClientModule[
|
|
TweetService.ServicePerEndpoint,
|
|
TweetService.MethodPerEndpoint
|
|
]
|
|
with MtlsClient {
|
|
override val label: String = "tweetypie"
|
|
override val dest: String = "/s/tweetypie/tweetypie"
|
|
|
|
@Singleton
|
|
@Provides
|
|
def providesTweetypieStitchClient(tweetService: TweetService.MethodPerEndpoint): TweetyPie =
|
|
new TweetyPie(tweetService)
|
|
|
|
/**
|
|
* TweetyPie client id must be in the form of {service.env} or it will not be treated as an
|
|
* unauthorized client
|
|
*/
|
|
override protected def clientId(injector: Injector): ClientId = {
|
|
val serviceIdentifier = injector.instance[ServiceIdentifier]
|
|
ClientId(s"${serviceIdentifier.service}.${serviceIdentifier.environment}")
|
|
}
|
|
|
|
override protected def configureMethodBuilder(
|
|
injector: Injector,
|
|
methodBuilder: MethodBuilder
|
|
): MethodBuilder =
|
|
methodBuilder
|
|
.withTimeoutPerRequest(500.milliseconds)
|
|
.withTimeoutTotal(500.milliseconds)
|
|
|
|
override protected def sessionAcquisitionTimeout: Duration = 250.milliseconds
|
|
}
|