Created
July 23, 2016 14:32
-
-
Save muuki88/35981220167fa9e186dd6375b3811c37 to your computer and use it in GitHub Desktop.
This file contains 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 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