mirror of
https://github.com/twitter/the-algorithm.git
synced 2024-06-01 08:48:46 +02:00
ef4c5eb65e
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.
27 lines
744 B
Scala
27 lines
744 B
Scala
package com.twitter.recosinjector.clients
|
|
|
|
import com.twitter.finagle.stats.StatsReceiver
|
|
import com.twitter.gizmoduck.thriftscala.User
|
|
import com.twitter.logging.Logger
|
|
import com.twitter.storehaus.ReadableStore
|
|
import com.twitter.util.Future
|
|
|
|
class Gizmoduck(
|
|
userStore: ReadableStore[Long, User]
|
|
)(
|
|
implicit statsReceiver: StatsReceiver) {
|
|
private val log = Logger()
|
|
private val stats = statsReceiver.scope(this.getClass.getSimpleName)
|
|
|
|
def getUser(userId: Long): Future[Option[User]] = {
|
|
userStore
|
|
.get(userId)
|
|
.rescue {
|
|
case e =>
|
|
stats.scope("getUserFailure").counter(e.getClass.getSimpleName).incr()
|
|
log.error(s"Failed with message ${e.toString}")
|
|
Future.None
|
|
}
|
|
}
|
|
}
|