com.twitter.finagle.zipkin.thriftscala.Scribe.scala Maven / Gradle / Ivy
/**
* Generated by Scrooge
* version: 4.10.0
* rev: 93b5383f7afff1301467b8941baf6ab35959a15c
* built at: 20160907-143258
*/
package com.twitter.finagle.zipkin.thriftscala
import com.twitter.scrooge.{
LazyTProtocol,
HasThriftStructCodec3,
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 Scribe[+MM[_]] extends ThriftService {
def log(messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]()): MM[com.twitter.finagle.zipkin.thriftscala.ResultCode]
}
object Scribe { self =>
case class ServiceIface(
log : com.twitter.finagle.Service[self.Log.Args, self.Log.Result]
) extends BaseServiceIface
// This is needed to support service inheritance.
trait BaseServiceIface extends ToThriftService {
def log : com.twitter.finagle.Service[self.Log.Args, self.Log.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(
log = ThriftServiceIface(self.Log, binaryService, pf, stats)
)
}
class MethodIface(serviceIface: BaseServiceIface)
extends Scribe[Future] {
private[this] val __log_service =
ThriftServiceIface.resultFilter(self.Log) andThen serviceIface.log
def log(messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]()): Future[com.twitter.finagle.zipkin.thriftscala.ResultCode] =
__log_service(self.Log.Args(messages))
}
implicit object MethodIfaceBuilder
extends com.twitter.finagle.thrift.MethodIfaceBuilder[ServiceIface, Scribe[Future]] {
def newMethodIface(serviceIface: ServiceIface): Scribe[Future] =
new MethodIface(serviceIface)
}
object Log extends com.twitter.scrooge.ThriftMethod {
object Args extends ThriftStructCodec3[Args] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("log_args")
val MessagesField = new TField("messages", TType.LIST, 1)
val MessagesFieldManifest = implicitly[Manifest[Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]]]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
MessagesField,
false,
false,
MessagesFieldManifest,
_root_.scala.None,
_root_.scala.Some(implicitly[Manifest[com.twitter.finagle.zipkin.thriftscala.LogEntry]]),
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
Some[Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]](Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]())
)
)
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(
messages =
{
val field = original.messages
field.map { field =>
com.twitter.finagle.zipkin.thriftscala.LogEntry.withoutPassthroughFields(field)
}
}
)
override def encode(_item: Args, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
override def decode(_iprot: TProtocol): Args = {
var messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]()
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.LIST =>
messages = readMessagesValue(_iprot)
case _actualType =>
val _expectedType = TType.LIST
throw new TProtocolException(
"Received wrong type for field 'messages' (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(
messages,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]()
): Args =
new Args(
messages
)
def unapply(_item: Args): _root_.scala.Option[Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]] = _root_.scala.Some(_item.messages)
@inline private def readMessagesValue(_iprot: TProtocol): Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = {
val _list = _iprot.readListBegin()
if (_list.size == 0) {
_iprot.readListEnd()
Nil
} else {
val _rv = new mutable$ArrayBuffer[com.twitter.finagle.zipkin.thriftscala.LogEntry](_list.size)
var _i = 0
while (_i < _list.size) {
_rv += {
com.twitter.finagle.zipkin.thriftscala.LogEntry.decode(_iprot)
}
_i += 1
}
_iprot.readListEnd()
_rv
}
}
@inline private def writeMessagesField(messages_item: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry], _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(MessagesField)
writeMessagesValue(messages_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeMessagesValue(messages_item: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry], _oprot: TProtocol): Unit = {
_oprot.writeListBegin(new TList(TType.STRUCT, messages_item.size))
messages_item match {
case _: IndexedSeq[_] =>
var _i = 0
val _size = messages_item.size
while (_i < _size) {
val messages_item_element = messages_item(_i)
messages_item_element.write(_oprot)
_i += 1
}
case _ =>
messages_item.foreach { messages_item_element =>
messages_item_element.write(_oprot)
}
}
_oprot.writeListEnd()
}
}
class Args(
val messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry],
val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ThriftStruct
with scala.Product1[Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]]
with HasThriftStructCodec3[Args]
with java.io.Serializable
{
import Args._
def this(
messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]()
) = this(
messages,
Map.empty
)
def _1 = messages
override def write(_oprot: TProtocol): Unit = {
Args.validate(this)
_oprot.writeStructBegin(Struct)
if (messages ne null) writeMessagesField(messages, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = this.messages,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): Args =
new Args(
messages,
_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.messages
case _ => throw new IndexOutOfBoundsException(n.toString)
}
override def productPrefix: String = "Args"
def _codec: ThriftStructCodec3[Args] = Args
}
type SuccessType = com.twitter.finagle.zipkin.thriftscala.ResultCode
object Result extends ThriftStructCodec3[Result] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("log_result")
val SuccessField = new TField("success", TType.ENUM, 0)
val SuccessFieldI32 = new TField("success", TType.I32, 0)
val SuccessFieldManifest = implicitly[Manifest[com.twitter.finagle.zipkin.thriftscala.ResultCode]]
/**
* 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],
None
)
)
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[com.twitter.finagle.zipkin.thriftscala.ResultCode] = _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.I32 | TType.ENUM =>
success = _root_.scala.Some(readSuccessValue(_iprot))
case _actualType =>
val _expectedType = TType.ENUM
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[com.twitter.finagle.zipkin.thriftscala.ResultCode] = _root_.scala.None
): Result =
new Result(
success
)
def unapply(_item: Result): _root_.scala.Option[_root_.scala.Option[com.twitter.finagle.zipkin.thriftscala.ResultCode]] = _root_.scala.Some(_item.success)
@inline private def readSuccessValue(_iprot: TProtocol): com.twitter.finagle.zipkin.thriftscala.ResultCode = {
com.twitter.finagle.zipkin.thriftscala.ResultCode.getOrUnknown(_iprot.readI32())
}
@inline private def writeSuccessField(success_item: com.twitter.finagle.zipkin.thriftscala.ResultCode, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(SuccessFieldI32)
writeSuccessValue(success_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeSuccessValue(success_item: com.twitter.finagle.zipkin.thriftscala.ResultCode, _oprot: TProtocol): Unit = {
_oprot.writeI32(success_item.value)
}
}
class Result(
val success: _root_.scala.Option[com.twitter.finagle.zipkin.thriftscala.ResultCode],
val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ThriftResponse[com.twitter.finagle.zipkin.thriftscala.ResultCode] with ThriftStruct
with scala.Product1[Option[com.twitter.finagle.zipkin.thriftscala.ResultCode]]
with HasThriftStructCodec3[Result]
with java.io.Serializable
{
import Result._
def this(
success: _root_.scala.Option[com.twitter.finagle.zipkin.thriftscala.ResultCode] = _root_.scala.None
) = this(
success,
Map.empty
)
def _1 = success
def successField: Option[com.twitter.finagle.zipkin.thriftscala.ResultCode] = 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[com.twitter.finagle.zipkin.thriftscala.ResultCode] = 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"
def _codec: ThriftStructCodec3[Result] = Result
}
type FunctionType = Function1[Args,Future[com.twitter.finagle.zipkin.thriftscala.ResultCode]]
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 = "Log"
val serviceName = "Scribe"
val argsCodec = Args
val responseCodec = Result
val oneway = false
}
// Compatibility aliases.
val log$args = Log.Args
type log$args = Log.Args
val log$result = Log.Result
type log$result = Log.Result
trait FutureIface extends Scribe[Future] {
def log(messages: Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry] = Seq[com.twitter.finagle.zipkin.thriftscala.LogEntry]()): Future[com.twitter.finagle.zipkin.thriftscala.ResultCode]
}
class FinagledClient(
service: com.twitter.finagle.Service[ThriftClientRequest, Array[Byte]],
protocolFactory: TProtocolFactory = Protocols.binaryFactory(),
serviceName: String = "Scribe",
stats: com.twitter.finagle.stats.StatsReceiver = com.twitter.finagle.stats.NullStatsReceiver,
responseClassifier: ctfs.ResponseClassifier = ctfs.ResponseClassifier.Default)
extends Scribe$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 Scribe$FinagleService(
iface,
protocolFactory)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy