diff --git a/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/FinagleThriftClient.scala b/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/FinagleThriftClient.scala deleted file mode 100644 index 1ae29a9d25..0000000000 --- a/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/FinagleThriftClient.scala +++ /dev/null @@ -1,55 +0,0 @@ -package com.twitter.finagle.scrooge - -import java.util.Arrays -import com.twitter.finagle.Service -import com.twitter.finagle.thrift.ThriftClientRequest -import com.twitter.util.Future -import org.apache.thrift.TApplicationException -import org.apache.thrift.protocol._ -import org.apache.thrift.transport.{TMemoryInputTransport, TMemoryBuffer} - -/** - * Common code used by any finagle thrift client code generated by scrooge. - */ -trait FinagleThriftClient { - val service: Service[ThriftClientRequest, Array[Byte]] - val protocolFactory: TProtocolFactory - - protected def encodeRequest(name: String, args: ThriftStruct): Future[ThriftClientRequest] = { - Future { - val buf = new TMemoryBuffer(512) - val oprot = this.protocolFactory.getProtocol(buf) - - oprot.writeMessageBegin(new TMessage(name, TMessageType.CALL, 0)) - args.write(oprot) - oprot.writeMessageEnd() - - val bytes = Arrays.copyOfRange(buf.getArray, 0, buf.length) - new ThriftClientRequest(bytes, false) - } - } - - protected def decodeResponse[T](resBytes: Array[Byte], decoder: TProtocol => T): Future[T] = { - Future { - val iprot = protocolFactory.getProtocol(new TMemoryInputTransport(resBytes)) - val msg = iprot.readMessageBegin() - try { - if (msg.`type` == TMessageType.EXCEPTION) { - throw TApplicationException.read(iprot) - } else { - decoder(iprot) - } - } finally { - iprot.readMessageEnd() - } - } - } - - protected def missingResult(name: String): Future[Nothing] = { - Future.exception { - new TApplicationException( - TApplicationException.MISSING_RESULT, - "`" + name + "` failed: unknown result") - } - } -} diff --git a/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/FinagleThriftService.scala b/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/FinagleThriftService.scala deleted file mode 100644 index 699c7d9a1e..0000000000 --- a/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/FinagleThriftService.scala +++ /dev/null @@ -1,64 +0,0 @@ -package com.twitter.finagle.scrooge - -import java.util.Arrays -import scala.collection.mutable -import com.twitter.finagle.Service -import com.twitter.util.Future -import org.apache.thrift.TApplicationException -import org.apache.thrift.protocol._ -import org.apache.thrift.transport.{TMemoryInputTransport, TMemoryBuffer} - -/** - * Common code used by any finagle thrift service code generated by scrooge. - */ -trait FinagleThriftService extends Service[Array[Byte], Array[Byte]] { - def protocolFactory: TProtocolFactory - - protected val functionMap = new mutable.HashMap[String, (TProtocol, Int) => Future[Array[Byte]]]() - - def exception(name: String, seqid: Int, code: Int, message: String): Future[Array[Byte]] = { - Future { - val x = new TApplicationException(code, message) - val memoryBuffer = new TMemoryBuffer(512) - val oprot = protocolFactory.getProtocol(memoryBuffer) - - oprot.writeMessageBegin(new TMessage(name, TMessageType.EXCEPTION, seqid)) - x.write(oprot) - oprot.writeMessageEnd() - oprot.getTransport.flush() - Arrays.copyOfRange(memoryBuffer.getArray, 0, memoryBuffer.length) - } - } - - def reply(name: String, seqid: Int, result: ThriftStruct): Future[Array[Byte]] = { - Future { - val memoryBuffer = new TMemoryBuffer(512) - val oprot = protocolFactory.getProtocol(memoryBuffer) - - oprot.writeMessageBegin(new TMessage(name, TMessageType.REPLY, seqid)) - result.write(oprot) - oprot.writeMessageEnd() - - Arrays.copyOfRange(memoryBuffer.getArray, 0, memoryBuffer.length) - } - } - - def apply(request: Array[Byte]): Future[Array[Byte]] = { - val inputTransport = new TMemoryInputTransport(request) - val iprot = protocolFactory.getProtocol(inputTransport) - - try { - val msg = iprot.readMessageBegin() - functionMap.get(msg.name) match { - case Some(f) => - f(iprot, msg.seqid) - case None => - TProtocolUtil.skip(iprot, TType.STRUCT) - iprot.readMessageEnd() - exception(msg.name, msg.seqid, TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'") - } - } catch { - case e: Exception => Future.exception(e) - } - } -} diff --git a/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/ThriftStruct.scala b/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/ThriftStruct.scala deleted file mode 100644 index e14749dc89..0000000000 --- a/finagle-scrooge/src/main/scala/com/twitter/finagle/scrooge/ThriftStruct.scala +++ /dev/null @@ -1,7 +0,0 @@ -package com.twitter.finagle.scrooge - -import org.apache.thrift.protocol.TProtocol - -trait ThriftStruct { - def write(oprot: TProtocol) -} diff --git a/project/build/Project.scala b/project/build/Project.scala index be1f47b15c..387680e9fd 100644 --- a/project/build/Project.scala +++ b/project/build/Project.scala @@ -133,14 +133,6 @@ class Project(info: ProjectInfo) extends StandardParentProject(info) "finagle-commons-stats", "finagle-commons-stats", new CommonsStatsProject(_), coreProject) - /** - * finagle-scrooge contains runtime classes for scrooge generated - * thrift structs and services. - */ - val scroogeProject = project( - "finagle-scrooge", "finagle-scrooge", - new ScroogeProject(_), thriftProject) - trait Defaults extends ProjectDependencies with DefaultRepos @@ -280,7 +272,4 @@ class Project(info: ProjectInfo) extends StandardParentProject(info) override def compileOrder = CompileOrder.JavaThenScala val commonsStats = "com.twitter.common" % "stats" % "0.0.16" } - - class ScroogeProject(info: ProjectInfo) extends StandardProject(info) - with Defaults }