scray.service.qservice.thrifscala.ScrayStatelessTService.scala Maven / Gradle / Ivy
/**
* Generated by Scrooge
* version: 4.16.0
* rev: 0201cac9fdd6188248d42da91fd14c87744cc4a5
* built at: 20170421-124523
*/
package scray.service.qservice.thrifscala
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
/**
* Stateless query service with indexed result pages
*/
@javax.annotation.Generated(value = Array("com.twitter.scrooge.Compiler"))
trait ScrayStatelessTService[+MM[_]] extends ThriftService {
/**
* Submit query
*/
def query(query: scray.service.qmodel.thrifscala.ScrayTQuery): MM[scray.service.qmodel.thrifscala.ScrayUUID]
/**
* Fetch query result pages by index.
* Paging state is to be maintained on client side.
* The operation is idempotent and safe.
*/
def getResults(queryId: scray.service.qmodel.thrifscala.ScrayUUID, pageIndex: Int): MM[scray.service.qservice.thrifscala.ScrayTResultFrame]
}
/**
* Stateless query service with indexed result pages
*/
object ScrayStatelessTService { self =>
val annotations: immutable$Map[String, String] = immutable$Map.empty
trait BaseServiceIface extends ToThriftService {
def query : com.twitter.finagle.Service[self.Query.Args, self.Query.SuccessType]
def getResults : com.twitter.finagle.Service[self.GetResults.Args, self.GetResults.SuccessType]
def toThriftService: ThriftService = new MethodIface(this)
}
case class ServiceIface(
query : com.twitter.finagle.Service[self.Query.Args, self.Query.SuccessType],
getResults : com.twitter.finagle.Service[self.GetResults.Args, self.GetResults.SuccessType]
) extends BaseServiceIface
with com.twitter.finagle.thrift.ThriftServiceIface.Filterable[ServiceIface] {
/**
* Prepends the given type-agnostic `Filter` to all of the `Services`
* and returns a copy of the `ServiceIface` now including the filter.
*/
def filtered(filter: com.twitter.finagle.Filter.TypeAgnostic): ServiceIface =
copy(
query = filter.toFilter.andThen(query),
getResults = filter.toFilter.andThen(getResults)
)
}
implicit object ServiceIfaceBuilder
extends com.twitter.finagle.thrift.ServiceIfaceBuilder[ServiceIface] {
def newServiceIface(
binaryService: com.twitter.finagle.Service[ThriftClientRequest, Array[Byte]],
pf: TProtocolFactory = com.twitter.finagle.thrift.Protocols.binaryFactory(),
stats: com.twitter.finagle.stats.StatsReceiver
): ServiceIface =
ServiceIface(
query = ThriftServiceIface(self.Query, binaryService, pf, stats),
getResults = ThriftServiceIface(self.GetResults, binaryService, pf, stats)
)
}
class MethodIface(serviceIface: BaseServiceIface)
extends ScrayStatelessTService[Future] {
def query(query: scray.service.qmodel.thrifscala.ScrayTQuery): Future[scray.service.qmodel.thrifscala.ScrayUUID] =
serviceIface.query(self.Query.Args(query))
def getResults(queryId: scray.service.qmodel.thrifscala.ScrayUUID, pageIndex: Int): Future[scray.service.qservice.thrifscala.ScrayTResultFrame] =
serviceIface.getResults(self.GetResults.Args(queryId, pageIndex))
}
implicit object MethodIfaceBuilder
extends com.twitter.finagle.thrift.MethodIfaceBuilder[ServiceIface, ScrayStatelessTService[Future]] {
def newMethodIface(serviceIface: ServiceIface): MethodIface =
new MethodIface(serviceIface)
}
object Query extends com.twitter.scrooge.ThriftMethod {
object Args extends ThriftStructCodec3[Args] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("query_args")
val QueryField = new TField("query", TType.STRUCT, 1)
val QueryFieldManifest = implicitly[Manifest[scray.service.qmodel.thrifscala.ScrayTQuery]]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
QueryField,
false,
false,
QueryFieldManifest,
_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: Args): Unit = {
}
def withoutPassthroughFields(original: Args): Args =
new Args(
query =
{
val field = original.query
scray.service.qmodel.thrifscala.ScrayTQuery.withoutPassthroughFields(field)
}
)
override def encode(_item: Args, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
override def decode(_iprot: TProtocol): Args = {
var query: scray.service.qmodel.thrifscala.ScrayTQuery = null
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.STRUCT =>
query = readQueryValue(_iprot)
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'query' (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(
query,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
query: scray.service.qmodel.thrifscala.ScrayTQuery
): Args =
new Args(
query
)
def unapply(_item: Args): _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayTQuery] = _root_.scala.Some(_item.query)
@inline private def readQueryValue(_iprot: TProtocol): scray.service.qmodel.thrifscala.ScrayTQuery = {
scray.service.qmodel.thrifscala.ScrayTQuery.decode(_iprot)
}
@inline private def writeQueryField(query_item: scray.service.qmodel.thrifscala.ScrayTQuery, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(QueryField)
writeQueryValue(query_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeQueryValue(query_item: scray.service.qmodel.thrifscala.ScrayTQuery, _oprot: TProtocol): Unit = {
query_item.write(_oprot)
}
}
class Args(
val query: scray.service.qmodel.thrifscala.ScrayTQuery,
val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ThriftStruct
with _root_.scala.Product1[scray.service.qmodel.thrifscala.ScrayTQuery]
with HasThriftStructCodec3[Args]
with java.io.Serializable
{
import Args._
def this(
query: scray.service.qmodel.thrifscala.ScrayTQuery
) = this(
query,
Map.empty
)
def _1 = query
override def write(_oprot: TProtocol): Unit = {
Args.validate(this)
_oprot.writeStructBegin(Struct)
if (query ne null) writeQueryField(query, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
query: scray.service.qmodel.thrifscala.ScrayTQuery = this.query,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): Args =
new Args(
query,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[Args]
private def _equals(x: Args, y: Args): Boolean =
x.productArity == y.productArity &&
x.productIterator.sameElements(y.productIterator)
override def equals(other: Any): Boolean =
canEqual(other) &&
_equals(this, other.asInstanceOf[Args]) &&
_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.query
case _ => throw new IndexOutOfBoundsException(n.toString)
}
override def productPrefix: String = "Args"
def _codec: ThriftStructCodec3[Args] = Args
}
type SuccessType = scray.service.qmodel.thrifscala.ScrayUUID
object Result extends ThriftStructCodec3[Result] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("query_result")
val SuccessField = new TField("success", TType.STRUCT, 0)
val SuccessFieldManifest = implicitly[Manifest[scray.service.qmodel.thrifscala.ScrayUUID]]
val ExField = new TField("ex", TType.STRUCT, 1)
val ExFieldManifest = implicitly[Manifest[scray.service.qservice.thrifscala.ScrayTException]]
/**
* 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
),
new ThriftStructFieldInfo(
ExField,
true,
false,
ExFieldManifest,
_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 =>
scray.service.qmodel.thrifscala.ScrayUUID.withoutPassthroughFields(field)
}
},
ex =
{
val field = original.ex
field.map { field =>
scray.service.qservice.thrifscala.ScrayTException.withoutPassthroughFields(field)
}
}
)
override def encode(_item: Result, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
override def decode(_iprot: TProtocol): Result = {
var success: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = _root_.scala.None
var ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = _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.STRUCT =>
success = _root_.scala.Some(readSuccessValue(_iprot))
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'success' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 1 =>
_field.`type` match {
case TType.STRUCT =>
ex = _root_.scala.Some(readExValue(_iprot))
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'ex' (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,
ex,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
success: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = _root_.scala.None,
ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = _root_.scala.None
): Result =
new Result(
success,
ex
)
def unapply(_item: Result): _root_.scala.Option[_root_.scala.Tuple2[Option[scray.service.qmodel.thrifscala.ScrayUUID], Option[scray.service.qservice.thrifscala.ScrayTException]]] = _root_.scala.Some(_item.toTuple)
@inline private def readSuccessValue(_iprot: TProtocol): scray.service.qmodel.thrifscala.ScrayUUID = {
scray.service.qmodel.thrifscala.ScrayUUID.decode(_iprot)
}
@inline private def writeSuccessField(success_item: scray.service.qmodel.thrifscala.ScrayUUID, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(SuccessField)
writeSuccessValue(success_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeSuccessValue(success_item: scray.service.qmodel.thrifscala.ScrayUUID, _oprot: TProtocol): Unit = {
success_item.write(_oprot)
}
@inline private def readExValue(_iprot: TProtocol): scray.service.qservice.thrifscala.ScrayTException = {
scray.service.qservice.thrifscala.ScrayTException.decode(_iprot)
}
@inline private def writeExField(ex_item: scray.service.qservice.thrifscala.ScrayTException, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(ExField)
writeExValue(ex_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeExValue(ex_item: scray.service.qservice.thrifscala.ScrayTException, _oprot: TProtocol): Unit = {
ex_item.write(_oprot)
}
}
class Result(
val success: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID],
val ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException],
val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ThriftResponse[scray.service.qmodel.thrifscala.ScrayUUID] with ThriftStruct
with _root_.scala.Product2[Option[scray.service.qmodel.thrifscala.ScrayUUID], Option[scray.service.qservice.thrifscala.ScrayTException]]
with HasThriftStructCodec3[Result]
with java.io.Serializable
{
import Result._
def this(
success: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = _root_.scala.None,
ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = _root_.scala.None
) = this(
success,
ex,
Map.empty
)
def _1 = success
def _2 = ex
def toTuple: _root_.scala.Tuple2[Option[scray.service.qmodel.thrifscala.ScrayUUID], Option[scray.service.qservice.thrifscala.ScrayTException]] = {
(
success,
ex
)
}
def successField: Option[scray.service.qmodel.thrifscala.ScrayUUID] = success
def exceptionFields: Iterable[Option[com.twitter.scrooge.ThriftException]] = Seq(ex)
override def write(_oprot: TProtocol): Unit = {
Result.validate(this)
_oprot.writeStructBegin(Struct)
if (success.isDefined) writeSuccessField(success.get, _oprot)
if (ex.isDefined) writeExField(ex.get, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
success: _root_.scala.Option[scray.service.qmodel.thrifscala.ScrayUUID] = this.success,
ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = this.ex,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): Result =
new Result(
success,
ex,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[Result]
private def _equals(x: Result, y: Result): Boolean =
x.productArity == y.productArity &&
x.productIterator.sameElements(y.productIterator)
override def equals(other: Any): Boolean =
canEqual(other) &&
_equals(this, other.asInstanceOf[Result]) &&
_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 = 2
override def productElement(n: Int): Any = n match {
case 0 => this.success
case 1 => this.ex
case _ => throw new IndexOutOfBoundsException(n.toString)
}
override def productPrefix: String = "Result"
def _codec: ThriftStructCodec3[Result] = Result
}
val annotations: immutable$Map[String, String] = immutable$Map.empty
type FunctionType = Function1[Args,Future[scray.service.qmodel.thrifscala.ScrayUUID]]
type ServiceType = com.twitter.finagle.Service[Args, Result]
type ServiceIfaceServiceType = com.twitter.finagle.Service[Args, SuccessType]
def toServiceIfaceService(f: FunctionType): ServiceIfaceServiceType =
com.twitter.finagle.Service.mk { args: Args =>
f(args)
}
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 =>
com.twitter.finagle.thrift.ThriftServiceIface.resultFilter(this).andThen(svc).apply(args)
}
val name: String = "query"
val serviceName: String = "ScrayStatelessTService"
val argsCodec = Args
val responseCodec = Result
val oneway: Boolean = false
}
// Compatibility aliases.
val query$args = Query.Args
type query$args = Query.Args
val query$result = Query.Result
type query$result = Query.Result
object GetResults extends com.twitter.scrooge.ThriftMethod {
object Args extends ThriftStructCodec3[Args] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("getResults_args")
val QueryIdField = new TField("queryId", TType.STRUCT, 1)
val QueryIdFieldManifest = implicitly[Manifest[scray.service.qmodel.thrifscala.ScrayUUID]]
val PageIndexField = new TField("pageIndex", TType.I32, 2)
val PageIndexFieldManifest = implicitly[Manifest[Int]]
/**
* Field information in declaration order.
*/
lazy val fieldInfos: scala.List[ThriftStructFieldInfo] = scala.List[ThriftStructFieldInfo](
new ThriftStructFieldInfo(
QueryIdField,
false,
false,
QueryIdFieldManifest,
_root_.scala.None,
_root_.scala.None,
immutable$Map.empty[String, String],
immutable$Map.empty[String, String],
None
),
new ThriftStructFieldInfo(
PageIndexField,
false,
false,
PageIndexFieldManifest,
_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: Args): Unit = {
}
def withoutPassthroughFields(original: Args): Args =
new Args(
queryId =
{
val field = original.queryId
scray.service.qmodel.thrifscala.ScrayUUID.withoutPassthroughFields(field)
},
pageIndex =
{
val field = original.pageIndex
field
}
)
override def encode(_item: Args, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
override def decode(_iprot: TProtocol): Args = {
var queryId: scray.service.qmodel.thrifscala.ScrayUUID = null
var pageIndex: Int = 0
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.STRUCT =>
queryId = readQueryIdValue(_iprot)
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'queryId' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 2 =>
_field.`type` match {
case TType.I32 =>
pageIndex = readPageIndexValue(_iprot)
case _actualType =>
val _expectedType = TType.I32
throw new TProtocolException(
"Received wrong type for field 'pageIndex' (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(
queryId,
pageIndex,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
queryId: scray.service.qmodel.thrifscala.ScrayUUID,
pageIndex: Int
): Args =
new Args(
queryId,
pageIndex
)
def unapply(_item: Args): _root_.scala.Option[_root_.scala.Tuple2[scray.service.qmodel.thrifscala.ScrayUUID, Int]] = _root_.scala.Some(_item.toTuple)
@inline private def readQueryIdValue(_iprot: TProtocol): scray.service.qmodel.thrifscala.ScrayUUID = {
scray.service.qmodel.thrifscala.ScrayUUID.decode(_iprot)
}
@inline private def writeQueryIdField(queryId_item: scray.service.qmodel.thrifscala.ScrayUUID, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(QueryIdField)
writeQueryIdValue(queryId_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeQueryIdValue(queryId_item: scray.service.qmodel.thrifscala.ScrayUUID, _oprot: TProtocol): Unit = {
queryId_item.write(_oprot)
}
@inline private def readPageIndexValue(_iprot: TProtocol): Int = {
_iprot.readI32()
}
@inline private def writePageIndexField(pageIndex_item: Int, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(PageIndexField)
writePageIndexValue(pageIndex_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writePageIndexValue(pageIndex_item: Int, _oprot: TProtocol): Unit = {
_oprot.writeI32(pageIndex_item)
}
}
class Args(
val queryId: scray.service.qmodel.thrifscala.ScrayUUID,
val pageIndex: Int,
val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ThriftStruct
with _root_.scala.Product2[scray.service.qmodel.thrifscala.ScrayUUID, Int]
with HasThriftStructCodec3[Args]
with java.io.Serializable
{
import Args._
def this(
queryId: scray.service.qmodel.thrifscala.ScrayUUID,
pageIndex: Int
) = this(
queryId,
pageIndex,
Map.empty
)
def _1 = queryId
def _2 = pageIndex
def toTuple: _root_.scala.Tuple2[scray.service.qmodel.thrifscala.ScrayUUID, Int] = {
(
queryId,
pageIndex
)
}
override def write(_oprot: TProtocol): Unit = {
Args.validate(this)
_oprot.writeStructBegin(Struct)
if (queryId ne null) writeQueryIdField(queryId, _oprot)
writePageIndexField(pageIndex, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
queryId: scray.service.qmodel.thrifscala.ScrayUUID = this.queryId,
pageIndex: Int = this.pageIndex,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): Args =
new Args(
queryId,
pageIndex,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[Args]
private def _equals(x: Args, y: Args): Boolean =
x.productArity == y.productArity &&
x.productIterator.sameElements(y.productIterator)
override def equals(other: Any): Boolean =
canEqual(other) &&
_equals(this, other.asInstanceOf[Args]) &&
_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 = 2
override def productElement(n: Int): Any = n match {
case 0 => this.queryId
case 1 => this.pageIndex
case _ => throw new IndexOutOfBoundsException(n.toString)
}
override def productPrefix: String = "Args"
def _codec: ThriftStructCodec3[Args] = Args
}
type SuccessType = scray.service.qservice.thrifscala.ScrayTResultFrame
object Result extends ThriftStructCodec3[Result] {
private val NoPassthroughFields = immutable$Map.empty[Short, TFieldBlob]
val Struct = new TStruct("getResults_result")
val SuccessField = new TField("success", TType.STRUCT, 0)
val SuccessFieldManifest = implicitly[Manifest[scray.service.qservice.thrifscala.ScrayTResultFrame]]
val ExField = new TField("ex", TType.STRUCT, 1)
val ExFieldManifest = implicitly[Manifest[scray.service.qservice.thrifscala.ScrayTException]]
/**
* 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
),
new ThriftStructFieldInfo(
ExField,
true,
false,
ExFieldManifest,
_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 =>
scray.service.qservice.thrifscala.ScrayTResultFrame.withoutPassthroughFields(field)
}
},
ex =
{
val field = original.ex
field.map { field =>
scray.service.qservice.thrifscala.ScrayTException.withoutPassthroughFields(field)
}
}
)
override def encode(_item: Result, _oproto: TProtocol): Unit = {
_item.write(_oproto)
}
override def decode(_iprot: TProtocol): Result = {
var success: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTResultFrame] = _root_.scala.None
var ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = _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.STRUCT =>
success = _root_.scala.Some(readSuccessValue(_iprot))
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'success' (expected=%s, actual=%s).".format(
ttypeToString(_expectedType),
ttypeToString(_actualType)
)
)
}
case 1 =>
_field.`type` match {
case TType.STRUCT =>
ex = _root_.scala.Some(readExValue(_iprot))
case _actualType =>
val _expectedType = TType.STRUCT
throw new TProtocolException(
"Received wrong type for field 'ex' (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,
ex,
if (_passthroughFields == null)
NoPassthroughFields
else
_passthroughFields.result()
)
}
def apply(
success: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTResultFrame] = _root_.scala.None,
ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = _root_.scala.None
): Result =
new Result(
success,
ex
)
def unapply(_item: Result): _root_.scala.Option[_root_.scala.Tuple2[Option[scray.service.qservice.thrifscala.ScrayTResultFrame], Option[scray.service.qservice.thrifscala.ScrayTException]]] = _root_.scala.Some(_item.toTuple)
@inline private def readSuccessValue(_iprot: TProtocol): scray.service.qservice.thrifscala.ScrayTResultFrame = {
scray.service.qservice.thrifscala.ScrayTResultFrame.decode(_iprot)
}
@inline private def writeSuccessField(success_item: scray.service.qservice.thrifscala.ScrayTResultFrame, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(SuccessField)
writeSuccessValue(success_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeSuccessValue(success_item: scray.service.qservice.thrifscala.ScrayTResultFrame, _oprot: TProtocol): Unit = {
success_item.write(_oprot)
}
@inline private def readExValue(_iprot: TProtocol): scray.service.qservice.thrifscala.ScrayTException = {
scray.service.qservice.thrifscala.ScrayTException.decode(_iprot)
}
@inline private def writeExField(ex_item: scray.service.qservice.thrifscala.ScrayTException, _oprot: TProtocol): Unit = {
_oprot.writeFieldBegin(ExField)
writeExValue(ex_item, _oprot)
_oprot.writeFieldEnd()
}
@inline private def writeExValue(ex_item: scray.service.qservice.thrifscala.ScrayTException, _oprot: TProtocol): Unit = {
ex_item.write(_oprot)
}
}
class Result(
val success: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTResultFrame],
val ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException],
val _passthroughFields: immutable$Map[Short, TFieldBlob])
extends ThriftResponse[scray.service.qservice.thrifscala.ScrayTResultFrame] with ThriftStruct
with _root_.scala.Product2[Option[scray.service.qservice.thrifscala.ScrayTResultFrame], Option[scray.service.qservice.thrifscala.ScrayTException]]
with HasThriftStructCodec3[Result]
with java.io.Serializable
{
import Result._
def this(
success: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTResultFrame] = _root_.scala.None,
ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = _root_.scala.None
) = this(
success,
ex,
Map.empty
)
def _1 = success
def _2 = ex
def toTuple: _root_.scala.Tuple2[Option[scray.service.qservice.thrifscala.ScrayTResultFrame], Option[scray.service.qservice.thrifscala.ScrayTException]] = {
(
success,
ex
)
}
def successField: Option[scray.service.qservice.thrifscala.ScrayTResultFrame] = success
def exceptionFields: Iterable[Option[com.twitter.scrooge.ThriftException]] = Seq(ex)
override def write(_oprot: TProtocol): Unit = {
Result.validate(this)
_oprot.writeStructBegin(Struct)
if (success.isDefined) writeSuccessField(success.get, _oprot)
if (ex.isDefined) writeExField(ex.get, _oprot)
if (_passthroughFields.nonEmpty) {
_passthroughFields.values.foreach { _.write(_oprot) }
}
_oprot.writeFieldStop()
_oprot.writeStructEnd()
}
def copy(
success: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTResultFrame] = this.success,
ex: _root_.scala.Option[scray.service.qservice.thrifscala.ScrayTException] = this.ex,
_passthroughFields: immutable$Map[Short, TFieldBlob] = this._passthroughFields
): Result =
new Result(
success,
ex,
_passthroughFields
)
override def canEqual(other: Any): Boolean = other.isInstanceOf[Result]
private def _equals(x: Result, y: Result): Boolean =
x.productArity == y.productArity &&
x.productIterator.sameElements(y.productIterator)
override def equals(other: Any): Boolean =
canEqual(other) &&
_equals(this, other.asInstanceOf[Result]) &&
_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 = 2
override def productElement(n: Int): Any = n match {
case 0 => this.success
case 1 => this.ex
case _ => throw new IndexOutOfBoundsException(n.toString)
}
override def productPrefix: String = "Result"
def _codec: ThriftStructCodec3[Result] = Result
}
val annotations: immutable$Map[String, String] = immutable$Map.empty
type FunctionType = Function1[Args,Future[scray.service.qservice.thrifscala.ScrayTResultFrame]]
type ServiceType = com.twitter.finagle.Service[Args, Result]
type ServiceIfaceServiceType = com.twitter.finagle.Service[Args, SuccessType]
def toServiceIfaceService(f: FunctionType): ServiceIfaceServiceType =
com.twitter.finagle.Service.mk { args: Args =>
f(args)
}
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 =>
com.twitter.finagle.thrift.ThriftServiceIface.resultFilter(this).andThen(svc).apply(args)
}
val name: String = "getResults"
val serviceName: String = "ScrayStatelessTService"
val argsCodec = Args
val responseCodec = Result
val oneway: Boolean = false
}
// Compatibility aliases.
val getResults$args = GetResults.Args
type getResults$args = GetResults.Args
val getResults$result = GetResults.Result
type getResults$result = GetResults.Result
trait FutureIface
extends ScrayStatelessTService[Future] {
/**
* Submit query
*/
def query(query: scray.service.qmodel.thrifscala.ScrayTQuery): Future[scray.service.qmodel.thrifscala.ScrayUUID]
/**
* Fetch query result pages by index.
* Paging state is to be maintained on client side.
* The operation is idempotent and safe.
*/
def getResults(queryId: scray.service.qmodel.thrifscala.ScrayUUID, pageIndex: Int): Future[scray.service.qservice.thrifscala.ScrayTResultFrame]
}
class FinagledClient(
service: com.twitter.finagle.Service[ThriftClientRequest, Array[Byte]],
protocolFactory: org.apache.thrift.protocol.TProtocolFactory = Protocols.binaryFactory(),
serviceName: String = "ScrayStatelessTService",
stats: com.twitter.finagle.stats.StatsReceiver = com.twitter.finagle.stats.NullStatsReceiver,
responseClassifier: ctfs.ResponseClassifier = ctfs.ResponseClassifier.Default)
extends ScrayStatelessTService$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: org.apache.thrift.protocol.TProtocolFactory)
extends ScrayStatelessTService$FinagleService(
iface,
protocolFactory)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy