Last active
March 11, 2016 21:46
-
-
Save vkostyukov/750196650f381e24c7aa to your computer and use it in GitHub Desktop.
TimeEndpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.finch._ | |
import com.twitter.finagle.stats._ | |
// See https://github.com/finagle/finch/issues/552 | |
def time[A](stat: Stat, e: Endpoint[A]): Endpoint[A] = new Endpoint[A] { | |
def apply(: Input): Endpoint.Result[A] = { | |
e(i).map { | |
case (remainder, output) => remainder -> output.map { f => | |
Stat.timeFuture(stat)(f) | |
} | |
} | |
} | |
} | |
// Usage | |
val e = get("users") { | |
Ok("users") | |
} | |
val eTimed = time(statsReceiver.stat(...), e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment