Skip to content

Instantly share code, notes, and snippets.

@muuki88
Created July 23, 2016 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muuki88/35981220167fa9e186dd6375b3811c37 to your computer and use it in GitHub Desktop.
Save muuki88/35981220167fa9e186dd6375b3811c37 to your computer and use it in GitHub Desktop.
import net.gutefrage.temperature.thrift._
import com.twitter.finagle.ThriftMux
// this is the raw implementation with the twitter Future based API
val service = new TemperatureService.FutureIface {
override def add(datum: TemperatureDatum): Future[Unit] = ???
override def mean(): Future[Double] = ???
}
// scrooge generates class to wrap a thrift service into a finagle compatible service definition
val finagledService = new TemperatureService.FinagledService(
service, Protocols.binaryFactory()
)
// run and announce the server
val server = ThriftMux.server
.withLabel("temperature-service")
.serveAndAnnounce(
// static announcemnt via zookeeper
name = "zk!127.0.0.1:2181!/service/temperature!0",
// bind this service to this address
addr = ":8082",
// the service to announce
service = finagledService
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment