2023-04-01 00:36:31 +02:00
|
|
|
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.stats.StatsReceiver
|
|
|
|
import com.twitter.inject.TwitterModule
|
2023-07-07 23:01:54 +02:00
|
|
|
import com.twitter.inject.annotations.Flag
|
2023-04-01 00:36:31 +02:00
|
|
|
import com.twitter.timelinemixer.clients.persistence.TimelinePersistenceManhattanClientBuilder
|
|
|
|
import com.twitter.timelinemixer.clients.persistence.TimelinePersistenceManhattanClientConfig
|
|
|
|
import com.twitter.timelinemixer.clients.persistence.TimelineResponseBatchesClient
|
|
|
|
import com.twitter.timelinemixer.clients.persistence.TimelineResponseV3
|
2023-07-07 23:01:54 +02:00
|
|
|
import com.twitter.util.Duration
|
2023-04-01 00:36:31 +02:00
|
|
|
import javax.inject.Singleton
|
|
|
|
|
|
|
|
object TimelinesPersistenceStoreClientModule extends TwitterModule {
|
|
|
|
private val StagingDataset = "timeline_response_batches_v5_nonprod"
|
|
|
|
private val ProdDataset = "timeline_response_batches_v5"
|
2023-07-07 23:01:54 +02:00
|
|
|
private final val Timeout = "mh_persistence_store.timeout"
|
|
|
|
|
|
|
|
flag[Duration](Timeout, 300.millis, "Timeout per request")
|
2023-04-01 00:36:31 +02:00
|
|
|
|
|
|
|
@Provides
|
|
|
|
@Singleton
|
|
|
|
def providesTimelinesPersistenceStoreClient(
|
2023-07-07 23:01:54 +02:00
|
|
|
@Flag(Timeout) timeout: Duration,
|
2023-04-01 00:36:31 +02:00
|
|
|
injectedServiceIdentifier: ServiceIdentifier,
|
|
|
|
statsReceiver: StatsReceiver
|
|
|
|
): TimelineResponseBatchesClient[TimelineResponseV3] = {
|
2023-07-07 23:01:54 +02:00
|
|
|
val timelineResponseBatchesDataset =
|
2023-04-01 00:36:31 +02:00
|
|
|
injectedServiceIdentifier.environment.toLowerCase match {
|
2023-07-07 23:01:54 +02:00
|
|
|
case "prod" => ProdDataset
|
|
|
|
case _ => StagingDataset
|
2023-04-01 00:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
val timelineResponseBatchesConfig = new TimelinePersistenceManhattanClientConfig {
|
|
|
|
val dataset = timelineResponseBatchesDataset
|
2023-07-07 23:01:54 +02:00
|
|
|
val isReadOnly = false
|
2023-04-01 00:36:31 +02:00
|
|
|
val serviceIdentifier = injectedServiceIdentifier
|
2023-07-07 23:01:54 +02:00
|
|
|
override val defaultMaxTimeout = timeout
|
|
|
|
override val maxRetryCount = 2
|
2023-04-01 00:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TimelinePersistenceManhattanClientBuilder.buildTimelineResponseV3BatchesClient(
|
|
|
|
timelineResponseBatchesConfig,
|
|
|
|
statsReceiver
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|