the-algorithm/cr-mixer/server/src/main/scala/com/twitter/cr_mixer/module/TweetRecentEngagedUserStoreModule.scala
twitter-team ef4c5eb65e Twitter Recommendation Algorithm
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.
2023-03-31 17:36:31 -05:00

43 lines
1.7 KiB
Scala

package com.twitter.cr_mixer.module
import com.google.inject.Provides
import com.google.inject.Singleton
import com.twitter.app.Flag
import com.twitter.finagle.stats.StatsReceiver
import com.twitter.frigate.common.store.strato.StratoFetchableStore
import com.twitter.hermit.store.common.ObservedReadableStore
import com.twitter.inject.TwitterModule
import com.twitter.simclusters_v2.common.TweetId
import com.twitter.storehaus.ReadableStore
import com.twitter.strato.client.{Client => StratoClient}
import com.twitter.twistly.thriftscala.TweetRecentEngagedUsers
object TweetRecentEngagedUserStoreModule extends TwitterModule {
private val tweetRecentEngagedUsersStoreDefaultVersion =
0 // DefaultVersion for tweetEngagedUsersStore, whose key = (tweetId, DefaultVersion)
private val tweetRecentEngagedUsersColumnPath: Flag[String] = flag[String](
name = "crMixer.tweetRecentEngagedUsersColumnPath",
default = "recommendations/twistly/tweetRecentEngagedUsers",
help = "Strato column path for TweetRecentEngagedUsersStore"
)
private type Version = Long
@Provides
@Singleton
def providesTweetRecentEngagedUserStore(
statsReceiver: StatsReceiver,
stratoClient: StratoClient,
): ReadableStore[TweetId, TweetRecentEngagedUsers] = {
val tweetRecentEngagedUsersStratoFetchableStore = StratoFetchableStore
.withUnitView[(TweetId, Version), TweetRecentEngagedUsers](
stratoClient,
tweetRecentEngagedUsersColumnPath()).composeKeyMapping[TweetId](tweetId =>
(tweetId, tweetRecentEngagedUsersStoreDefaultVersion))
ObservedReadableStore(
tweetRecentEngagedUsersStratoFetchableStore
)(statsReceiver.scope("tweet_recent_engaged_users_store"))
}
}