-
-
Save DylanLukes/eb775e0818c93cb1dc6e56d46f321d31 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
namespace java com.einhornmediagroup.agent.thriftjava | |
#@namespace scala com.einhornmediagroup.agent.thriftscala | |
service BinaryService { | |
binary fetchBlob(1: i64 id); | |
} |
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
/** | |
* Generated by Scrooge | |
* version: 4.8.0 | |
* rev: a96517ce2f542026f7c02451c8ef8d33bc7e319d | |
* built at: 20160708-092458 | |
*/ | |
package com.einhornmediagroup.agent.thriftscala | |
import com.twitter.scrooge.{ | |
LazyTProtocol, | |
TFieldBlob, ThriftService, ThriftStruct, | |
ThriftStructCodec, ThriftStructCodec3, | |
ThriftStructFieldInfo, ThriftResponse, ThriftUtil, ToThriftService} | |
import com.twitter.finagle.{service => ctfs} | |
import com.twitter.finagle.thrift.{Protocols, ThriftClientRequest, ThriftServiceIface} | |
import com.twitter.util.Future | |
import java.nio.ByteBuffer | |
import java.util.Arrays | |
import org.apache.thrift.protocol._ | |
import org.apache.thrift.transport.TTransport | |
import org.apache.thrift.TApplicationException | |
import org.apache.thrift.transport.TMemoryBuffer | |
import scala.collection.immutable.{Map => immutable$Map} | |
import scala.collection.mutable.{ | |
Builder, | |
ArrayBuffer => mutable$ArrayBuffer, Buffer => mutable$Buffer, | |
HashMap => mutable$HashMap, HashSet => mutable$HashSet} | |
import scala.collection.{Map, Set} | |
import scala.language.higherKinds | |
@javax.annotation.Generated(value = Array("com.twitter.scrooge.Compiler")) | |
trait BinaryService[+MM[_]] extends ThriftService { | |
def fetchBlob(id: Long): MM[ByteBuffer] | |
} | |
object BinaryService { self => | |
case class ServiceIface( | |
fetchBlob : com.twitter.finagle.Service[self.FetchBlob.Args, self.FetchBlob.Result] | |
) extends BaseServiceIface | |
// This is needed to support service inheritance. | |
trait BaseServiceIface extends ToThriftService { | |
def fetchBlob : com.twitter.finagle.Service[self.FetchBlob.Args, self.FetchBlob.Result] | |
override def toThriftService: ThriftService = new MethodIface(this) | |
} | |
implicit object ServiceIfaceBuilder | |
extends com.twitter.finagle.thrift.ServiceIfaceBuilder[ServiceIface] { | |
def newServiceIface( | |
binaryService: com.twitter.finagle.Service[ThriftClientRequest, Array[Byte]], | |
pf: TProtocolFactory = Protocols.binaryFactory(), | |
stats: com.twitter.finagle.stats.StatsReceiver | |
): ServiceIface = | |
new ServiceIface( | |
fetchBlob = ThriftServiceIface(self.FetchBlob, binaryService, pf, stats) | |
) | |
} | |
class MethodIface(serviceIface: BaseServiceIface) | |
extends BinaryService[Future] { | |
private[this] val __fetchBlob_service = | |
ThriftServiceIface.resultFilter(self.FetchBlob) andThen serviceIface.fetchBlob | |
def fetchBlob(id: Long): Future[ByteBuffer] = | |
__fetchBlob_service(self.FetchBlob.Args(id)) | |
} | |
implicit object MethodIfaceBuilder | |
extends com.twitter.finagle.thrift.MethodIfaceBuilder[ServiceIface, BinaryService[Future]] { | |
def newMethodIface(serviceIface: ServiceIface): BinaryService[Future] = | |
new MethodIface(serviceIface) | |
} | |
object FetchBlob extends com.twitter.scrooge.ThriftMethod { | |
object Args extends ThriftStructCodec3[Args] { | |
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob] | |
val Struct = new TStruct("fetchBlob_args") | |
val IdField = new TField("id", TType.I64, 1) | |
val IdFieldManifest = implicitly[Manifest[Long]] | |
/** | |
* Field information in declaration order. | |
*/ | |
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo]( | |
new ThriftStructFieldInfo( | |
IdField, | |
false, | |
false, | |
IdFieldManifest, | |
_root_.scala.None, | |
_root_.scala.None, | |
immutable$Map.empty[String, String], | |
immutable$Map.empty[String, String] | |
) | |
) | |
lazy val structAnnotations: immutable$Map[String, String] = | |
immutable$Map.empty[String, String] | |
/** | |
* Checks that all required fields are non-null. | |
*/ | |
def validate(_item: Args): Unit = { | |
} | |
def withoutPassthroughFields(original: Args): Args = | |
new Args( | |
id = | |
{ | |
val field = original.id | |
field | |
} | |
) | |
override def encode(_item: Args, _oproto: TProtocol): Unit = { | |
_item.write(_oproto) | |
} | |
override def decode(_iprot: TProtocol): Args = { | |
var id: Long = 0L | |
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null | |
var _done = false | |
_iprot.readStructBegin() | |
while (!_done) { | |
val _field = _iprot.readFieldBegin() | |
if (_field.`type` == TType.STOP) { | |
_done = true | |
} else { | |
_field.id match { | |
case 1 => | |
_field.`type` match { | |
case TType.I64 => | |
id = readIdValue(_iprot) | |
case _actualType => | |
val _expectedType = TType.I64 | |
throw new TProtocolException( | |
"Received wrong type for field 'id' (expected=%s, actual=%s).".format( | |
ttypeToString(_expectedType), | |
ttypeToString(_actualType) | |
) | |
) | |
} | |
case _ => | |
if (_passthroughFields == null) | |
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob] | |
_passthroughFields += (_field.id -> TFieldBlob.read(_field, _iprot)) | |
} | |
_iprot.readFieldEnd() | |
} | |
} | |
_iprot.readStructEnd() | |
new Args( | |
id, | |
if (_passthroughFields == null) | |
NoPassthroughFields | |
else | |
_passthroughFields.result() | |
) | |
} | |
def apply( | |
id: Long | |
): Args = | |
new Args( | |
id | |
) | |
def unapply(_item: Args): _root_.scala.Option[Long] = _root_.scala.Some(_item.id) | |
@inline private def readIdValue(_iprot: TProtocol): Long = { | |
_iprot.readI64() | |
} | |
@inline private def writeIdField(id_item: Long, _oprot: TProtocol): Unit = { | |
_oprot.writeFieldBegin(IdField) | |
writeIdValue(id_item, _oprot) | |
_oprot.writeFieldEnd() | |
} | |
@inline private def writeIdValue(id_item: Long, _oprot: TProtocol): Unit = { | |
_oprot.writeI64(id_item) | |
} | |
} | |
class Args( | |
val id: Long, | |
val _passthroughFields: immutable$Map[Short, TFieldBlob]) | |
extends ThriftStruct | |
with scala.Product1[Long] | |
with java.io.Serializable | |
{ | |
import Args._ | |
def this( | |
id: Long | |
) = this( | |
id, | |
Map.empty | |
) | |
def _1 = id | |
override def write(_oprot: TProtocol): Unit = { | |
Args.validate(this) | |
_oprot.writeStructBegin(Struct) | |
writeIdField(id, _oprot) | |
if (_passthroughFields.nonEmpty) { | |
_passthroughFields.values.foreach { _.write(_oprot) } | |
} | |
_oprot.writeFieldStop() | |
_oprot.writeStructEnd() | |
} | |
def copy( | |
id: Long = this.id, | |
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields | |
): Args = | |
new Args( | |
id, | |
_passthroughFields | |
) | |
override def canEqual(other: Any): Boolean = other.isInstanceOf[Args] | |
override def equals(other: Any): Boolean = | |
canEqual(other) && | |
_root_.scala.runtime.ScalaRunTime._equals(this, other) && | |
_passthroughFields == other.asInstanceOf[Args]._passthroughFields | |
override def hashCode: Int = _root_.scala.runtime.ScalaRunTime._hashCode(this) | |
override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this) | |
override def productArity: Int = 1 | |
override def productElement(n: Int): Any = n match { | |
case 0 => this.id | |
case _ => throw new IndexOutOfBoundsException(n.toString) | |
} | |
override def productPrefix: String = "Args" | |
} | |
type SuccessType = ByteBuffer | |
object Result extends ThriftStructCodec3[Result] { | |
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob] | |
val Struct = new TStruct("fetchBlob_result") | |
val SuccessField = new TField("success", TType.STRING, 0) | |
val SuccessFieldManifest = implicitly[Manifest[ByteBuffer]] | |
/** | |
* Field information in declaration order. | |
*/ | |
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo]( | |
new ThriftStructFieldInfo( | |
SuccessField, | |
true, | |
false, | |
SuccessFieldManifest, | |
_root_.scala.None, | |
_root_.scala.None, | |
immutable$Map.empty[String, String], | |
immutable$Map.empty[String, String] | |
) | |
) | |
lazy val structAnnotations: immutable$Map[String, String] = | |
immutable$Map.empty[String, String] | |
/** | |
* Checks that all required fields are non-null. | |
*/ | |
def validate(_item: Result): Unit = { | |
} | |
def withoutPassthroughFields(original: Result): Result = | |
new Result( | |
success = | |
{ | |
val field = original.success | |
field.map { field => | |
field | |
} | |
} | |
) | |
override def encode(_item: Result, _oproto: TProtocol): Unit = { | |
_item.write(_oproto) | |
} | |
override def decode(_iprot: TProtocol): Result = { | |
var success: _root_.scala.Option[ByteBuffer] = _root_.scala.None | |
var _passthroughFields: Builder[(Short, TFieldBlob), immutable$Map[Short, TFieldBlob]] = null | |
var _done = false | |
_iprot.readStructBegin() | |
while (!_done) { | |
val _field = _iprot.readFieldBegin() | |
if (_field.`type` == TType.STOP) { | |
_done = true | |
} else { | |
_field.id match { | |
case 0 => | |
_field.`type` match { | |
case TType.STRING => | |
success = _root_.scala.Some(readSuccessValue(_iprot)) | |
case _actualType => | |
val _expectedType = TType.STRING | |
throw new TProtocolException( | |
"Received wrong type for field 'success' (expected=%s, actual=%s).".format( | |
ttypeToString(_expectedType), | |
ttypeToString(_actualType) | |
) | |
) | |
} | |
case _ => | |
if (_passthroughFields == null) | |
_passthroughFields = immutable$Map.newBuilder[Short, TFieldBlob] | |
_passthroughFields += (_field.id -> TFieldBlob.read(_field, _iprot)) | |
} | |
_iprot.readFieldEnd() | |
} | |
} | |
_iprot.readStructEnd() | |
new Result( | |
success, | |
if (_passthroughFields == null) | |
NoPassthroughFields | |
else | |
_passthroughFields.result() | |
) | |
} | |
def apply( | |
success: _root_.scala.Option[ByteBuffer] = _root_.scala.None | |
): Result = | |
new Result( | |
success | |
) | |
def unapply(_item: Result): _root_.scala.Option[_root_.scala.Option[ByteBuffer]] = _root_.scala.Some(_item.success) | |
@inline private def readSuccessValue(_iprot: TProtocol): ByteBuffer = { | |
_iprot.readBinary() | |
} | |
@inline private def writeSuccessField(success_item: ByteBuffer, _oprot: TProtocol): Unit = { | |
_oprot.writeFieldBegin(SuccessField) | |
writeSuccessValue(success_item, _oprot) | |
_oprot.writeFieldEnd() | |
} | |
@inline private def writeSuccessValue(success_item: ByteBuffer, _oprot: TProtocol): Unit = { | |
_oprot.writeBinary(success_item) | |
} | |
} | |
class Result( | |
val success: _root_.scala.Option[ByteBuffer], | |
val _passthroughFields: immutable$Map[Short, TFieldBlob]) | |
extends ThriftResponse[ByteBuffer] with ThriftStruct | |
with scala.Product1[Option[ByteBuffer]] | |
with java.io.Serializable | |
{ | |
import Result._ | |
def this( | |
success: _root_.scala.Option[ByteBuffer] = _root_.scala.None | |
) = this( | |
success, | |
Map.empty | |
) | |
def _1 = success | |
def successField: Option[ByteBuffer] = success | |
def exceptionFields: Iterable[Option[com.twitter.scrooge.ThriftException]] = Seq() | |
override def write(_oprot: TProtocol): Unit = { | |
Result.validate(this) | |
_oprot.writeStructBegin(Struct) | |
if (success.isDefined) writeSuccessField(success.get, _oprot) | |
if (_passthroughFields.nonEmpty) { | |
_passthroughFields.values.foreach { _.write(_oprot) } | |
} | |
_oprot.writeFieldStop() | |
_oprot.writeStructEnd() | |
} | |
def copy( | |
success: _root_.scala.Option[ByteBuffer] = this.success, | |
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields | |
): Result = | |
new Result( | |
success, | |
_passthroughFields | |
) | |
override def canEqual(other: Any): Boolean = other.isInstanceOf[Result] | |
override def equals(other: Any): Boolean = | |
canEqual(other) && | |
_root_.scala.runtime.ScalaRunTime._equals(this, other) && | |
_passthroughFields == other.asInstanceOf[Result]._passthroughFields | |
override def hashCode: Int = _root_.scala.runtime.ScalaRunTime._hashCode(this) | |
override def toString: String = _root_.scala.runtime.ScalaRunTime._toString(this) | |
override def productArity: Int = 1 | |
override def productElement(n: Int): Any = n match { | |
case 0 => this.success | |
case _ => throw new IndexOutOfBoundsException(n.toString) | |
} | |
override def productPrefix: String = "Result" | |
} | |
type FunctionType = Function1[Args,Future[ByteBuffer]] | |
type ServiceType = com.twitter.finagle.Service[Args, Result] | |
private[this] val toResult = (res: SuccessType) => Result(Some(res)) | |
def functionToService(f: FunctionType): ServiceType = { | |
com.twitter.finagle.Service.mk { args: Args => | |
f(args).map(toResult) | |
} | |
} | |
def serviceToFunction(svc: ServiceType): FunctionType = { args: Args => | |
ThriftServiceIface.resultFilter(this).andThen(svc).apply(args) | |
} | |
val name = "fetchBlob" | |
val serviceName = "BinaryService" | |
val argsCodec = Args | |
val responseCodec = Result | |
val oneway = false | |
} | |
// Compatibility aliases. | |
val fetchBlob$args = FetchBlob.Args | |
type fetchBlob$args = FetchBlob.Args | |
val fetchBlob$result = FetchBlob.Result | |
type fetchBlob$result = FetchBlob.Result | |
trait FutureIface extends BinaryService[Future] { | |
def fetchBlob(id: Long): Future[ByteBuffer] | |
} | |
class FinagledClient( | |
service: com.twitter.finagle.Service[ThriftClientRequest, Array[Byte]], | |
protocolFactory: TProtocolFactory = Protocols.binaryFactory(), | |
serviceName: String = "BinaryService", | |
stats: com.twitter.finagle.stats.StatsReceiver = com.twitter.finagle.stats.NullStatsReceiver, | |
responseClassifier: ctfs.ResponseClassifier = ctfs.ResponseClassifier.Default) | |
extends BinaryService$FinagleClient( | |
service, | |
protocolFactory, | |
serviceName, | |
stats, | |
responseClassifier) | |
with FutureIface { | |
def this( | |
service: com.twitter.finagle.Service[ThriftClientRequest, Array[Byte]], | |
protocolFactory: TProtocolFactory, | |
serviceName: String, | |
stats: com.twitter.finagle.stats.StatsReceiver | |
) = this(service, protocolFactory, serviceName, stats, ctfs.ResponseClassifier.Default) | |
} | |
class FinagledService( | |
iface: FutureIface, | |
protocolFactory: TProtocolFactory) | |
extends BinaryService$FinagleService( | |
iface, | |
protocolFactory) | |
} |
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
resolvers += "twitter-repo" at "https://maven.twttr.com" | |
libraryDependencies += "org.scalafx" %% "scalafx" % "8.0.92-R10" | |
libraryDependencies ++= Seq( | |
"org.apache.thrift" % "libthrift" % "0.5.0-1", | |
"com.twitter" %% "finagle-core" % "6.36.0", | |
"com.twitter" %% "finagle-thrift" % "6.36.0", | |
"com.twitter" %% "scrooge-core" % "4.8.0" | |
) | |
// This tells SBT to run builds in their own JVM. This avoids Ctrl-C killing SBT. | |
fork in run := true | |
// Enables support for SAMs (i.e. implicit conversion of anonymous functions | |
// to single-abstract-method classes such as Runnable and EventListener) | |
scalacOptions += "-Xexperimental" |
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
[info] Generating scrooge thrift for /Users/dylan/EMG/Projects/SlideDeck/agent/src/main/thrift/Agent.thrift ... | |
[info] Compiling 4 Scala sources to /Users/dylan/EMG/Projects/SlideDeck/agent/target/scala-2.11/classes... | |
[error] /Users/dylan/EMG/Projects/SlideDeck/agent/target/scala-2.11/src_managed/main/com/einhornmediagroup/agent/thriftscala/BinaryService.scala:68: ambiguous reference to overloaded definition, | |
[error] both method andThen in class Filter of type (f: com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args => com.twitter.util.Future[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Result])com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args => com.twitter.util.Future[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.SuccessType] | |
[error] and method andThen in class Filter of type (service: com.twitter.finagle.Service[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args,com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Result])com.twitter.finagle.Service[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args,com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.SuccessType] | |
[error] match argument types (com.twitter.finagle.Service[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args,com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Result]) | |
[error] ThriftServiceIface.resultFilter(self.FetchBlob) andThen serviceIface.fetchBlob | |
[error] ^ | |
[error] /Users/dylan/EMG/Projects/SlideDeck/agent/target/scala-2.11/src_managed/main/com/einhornmediagroup/agent/thriftscala/BinaryService.scala:451: ambiguous reference to overloaded definition, | |
[error] both method andThen in class Filter of type (f: com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args => com.twitter.util.Future[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Result])com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args => com.twitter.util.Future[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.SuccessType] | |
[error] and method andThen in class Filter of type (service: com.twitter.finagle.Service[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args,com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Result])com.twitter.finagle.Service[com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.Args,com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.SuccessType] | |
[error] match argument types (com.einhornmediagroup.agent.thriftscala.BinaryService.FetchBlob.ServiceType) | |
[error] ThriftServiceIface.resultFilter(this).andThen(svc).apply(args) | |
[error] ^ | |
[error] two errors found | |
[error] (agent/compile:compileIncremental) Compilation failed | |
[error] Total time: 1 s, completed Jul 14, 2016 12:10:29 PM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment