mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-02 06:58:25 +00:00
94ff4caea8
Topic Social Proof Service (TSPS) delivers highly relevant topics tailored to a user's interests by analyzing topic preferences, such as following or unfollowing, and employing semantic annotations and other machine learning models.
42 lines
1.4 KiB
Scala
42 lines
1.4 KiB
Scala
package com.twitter.tsp.modules
|
|
|
|
import com.google.inject.Provides
|
|
import com.twitter.escherbird.util.uttclient.CacheConfigV2
|
|
import com.twitter.escherbird.util.uttclient.CachedUttClientV2
|
|
import com.twitter.escherbird.util.uttclient.UttClientCacheConfigsV2
|
|
import com.twitter.escherbird.utt.strato.thriftscala.Environment
|
|
import com.twitter.finagle.stats.StatsReceiver
|
|
import com.twitter.inject.TwitterModule
|
|
import com.twitter.strato.client.Client
|
|
import com.twitter.topiclisting.clients.utt.UttClient
|
|
import javax.inject.Singleton
|
|
|
|
object UttClientModule extends TwitterModule {
|
|
|
|
@Provides
|
|
@Singleton
|
|
def providesUttClient(
|
|
stratoClient: Client,
|
|
statsReceiver: StatsReceiver
|
|
): UttClient = {
|
|
|
|
// Save 2 ^ 18 UTTs. Promising 100% cache rate
|
|
lazy val defaultCacheConfigV2: CacheConfigV2 = CacheConfigV2(262143)
|
|
lazy val uttClientCacheConfigsV2: UttClientCacheConfigsV2 = UttClientCacheConfigsV2(
|
|
getTaxonomyConfig = defaultCacheConfigV2,
|
|
getUttTaxonomyConfig = defaultCacheConfigV2,
|
|
getLeafIds = defaultCacheConfigV2,
|
|
getLeafUttEntities = defaultCacheConfigV2
|
|
)
|
|
|
|
// CachedUttClient to use StratoClient
|
|
lazy val cachedUttClientV2: CachedUttClientV2 = new CachedUttClientV2(
|
|
stratoClient = stratoClient,
|
|
env = Environment.Prod,
|
|
cacheConfigs = uttClientCacheConfigsV2,
|
|
statsReceiver = statsReceiver.scope("CachedUttClient")
|
|
)
|
|
new UttClient(cachedUttClientV2, statsReceiver)
|
|
}
|
|
}
|