Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package twitter

    Start with com.twitter.finagle.

    Definition Classes
    com
  • package finagle

    Finagle is an extensible RPC system.

    Finagle is an extensible RPC system.

    Services are represented by class com.twitter.finagle.Service. Clients make use of com.twitter.finagle.Service objects while servers implement them.

    Finagle contains a number of protocol implementations; each of these implement Client and/or com.twitter.finagle.Server. For example, Finagle's HTTP implementation, com.twitter.finagle.Http (in package finagle-http), exposes both.

    Thus a simple HTTP server is built like this:

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Await, Future}
    
    val service = new Service[Request, Response] {
      def apply(req: Request): Future[Response] =
        Future.value(Response())
    }
    val server = Http.server.serve(":8080", service)
    Await.ready(server)

    We first define a service to which requests are dispatched. In this case, the service returns immediately with a HTTP 200 OK response, and with no content.

    This service is then served via the Http protocol on TCP port 8080. Finally we wait for the server to stop serving.

    We can now query our web server:

    % curl -D - localhost:8080
    HTTP/1.1 200 OK

    Building an HTTP client is also simple. (Note that type annotations are added for illustration.)

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Future, Return, Throw}
    
    val client: Service[Request, Response] = Http.client.newService("localhost:8080")
    val f: Future[Response] = client(Request()).respond {
      case Return(rep) =>
        printf("Got HTTP response %s\n", rep)
      case Throw(exc) =>
        printf("Got error %s\n", exc)
    }

    Http.client.newService("localhost:8080") constructs a new com.twitter.finagle.Service instance connected to localhost TCP port 8080. We then issue a HTTP/1.1 GET request to URI "/". The service returns a com.twitter.util.Future representing the result of the operation. We listen to this future, printing an appropriate message when the response arrives.

    The Finagle homepage contains useful documentation and resources for using Finagle.

    Definition Classes
    twitter
  • package thrift

    Please use the new interface, com.twitter.finagle.Thrift, for constructing Thrift clients and servers.

    Deprecation

    Please use the new interface, com.twitter.finagle.Thrift, for constructing Thrift clients and servers.

    Thrift codecs

    We provide client and server protocol support for the framed protocol. The public implementations are defined on the Thrift object:

    The type of the server codec is Service[Array[Byte], Array[Byte]] and the client codecs are Service[ThriftClientRequest, Array[Byte]]. The service provided is that of a "transport" of thrift messages (requests and replies) according to the protocol chosen. This is why the client codecs need to have access to a thrift ProtocolFactory.

    These transports are used by the services produced by the finagle thrift codegenerator.

    val service: Service[ThriftClientRequest, Array[Byte]] = ClientBuilder()
      .hosts("foobar.com:123")
      .stack(Thrift.client)
      .build()
    
    // Wrap the raw Thrift transport in a Client decorator. The client
    // provides a convenient procedural interface for accessing the Thrift
    // server.
    val client = new Hello.ServiceToClient(service, protocolFactory)

    In this example, Hello is the thrift interface, and the inner class ServiceToClient is provided by the finagle thrift code generator.

    Definition Classes
    finagle
  • package service
    Definition Classes
    thrift
  • package thrift
    Definition Classes
    thrift
  • package thriftscala
    Definition Classes
    thrift
  • Annotation
  • AnnotationType
  • BinaryAnnotation
  • ClientId
  • ConnectionOptions
  • Constants
  • Delegation
  • Endpoint
  • RequestContext
  • RequestHeader
  • ResponseHeader
  • Span
  • UpgradeReply

package thriftscala

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait Annotation extends ThriftStruct with Product3[Long, String, Option[Endpoint]] with HasThriftStructCodec3[Annotation] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.Annotation.apply for construction if you don't need to specify passthrough fields.

  2. sealed trait AnnotationType extends ThriftEnum with Serializable
    Annotations
    @Generated()
  3. trait BinaryAnnotation extends ThriftStruct with Product4[String, ByteBuffer, AnnotationType, Option[Endpoint]] with HasThriftStructCodec3[BinaryAnnotation] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.BinaryAnnotation.apply for construction if you don't need to specify passthrough fields.

  4. trait ClientId extends ThriftStruct with Product1[String] with HasThriftStructCodec3[ClientId] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.ClientId.apply for construction if you don't need to specify passthrough fields.

  5. trait ConnectionOptions extends ThriftStruct with Product with HasThriftStructCodec3[ConnectionOptions] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.ConnectionOptions.apply for construction if you don't need to specify passthrough fields.

  6. trait Delegation extends ThriftStruct with Product2[String, String] with HasThriftStructCodec3[Delegation] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.Delegation.apply for construction if you don't need to specify passthrough fields.

  7. trait Endpoint extends ThriftStruct with Product3[Int, Short, String] with HasThriftStructCodec3[Endpoint] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.Endpoint.apply for construction if you don't need to specify passthrough fields.

  8. trait RequestContext extends ThriftStruct with Product2[ByteBuffer, ByteBuffer] with HasThriftStructCodec3[RequestContext] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.RequestContext.apply for construction if you don't need to specify passthrough fields.

  9. trait RequestHeader extends ThriftStruct with Product10[Long, Long, Option[Long], Option[Boolean], Option[ClientId], Option[Long], Seq[RequestContext], Option[String], Option[Seq[Delegation]], Option[Long]] with HasThriftStructCodec3[RequestHeader] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.RequestHeader.apply for construction if you don't need to specify passthrough fields.

  10. trait ResponseHeader extends ThriftStruct with Product2[Seq[Span], Seq[RequestContext]] with HasThriftStructCodec3[ResponseHeader] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.ResponseHeader.apply for construction if you don't need to specify passthrough fields.

  11. trait Span extends ThriftStruct with Product7[Long, String, Long, Option[Long], Seq[Annotation], Seq[BinaryAnnotation], Boolean] with HasThriftStructCodec3[Span] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.Span.apply for construction if you don't need to specify passthrough fields.

  12. trait UpgradeReply extends ThriftStruct with Product with HasThriftStructCodec3[UpgradeReply] with Serializable

    Prefer the companion object's com.twitter.finagle.thrift.thriftscala.UpgradeReply.apply for construction if you don't need to specify passthrough fields.

Value Members

  1. object Annotation extends ThriftStructCodec3[Annotation] with Serializable

    An annotation is similar to a log statement.

    An annotation is similar to a log statement. It includes a host field which allows these events to be attributed properly, and also aggregatable.

  2. object AnnotationType extends Product with Serializable
    Annotations
    @Generated()
  3. object BinaryAnnotation extends ThriftStructCodec3[BinaryAnnotation] with Serializable

    Binary annotations are tags applied to a Span to give it context.

    Binary annotations are tags applied to a Span to give it context. For example, a binary annotation of "http.uri" could the path to a resource in a RPC call.

    Binary annotations of type STRING are always queryable, though more a historical implementation detail than a structural concern.

    Binary annotations can repeat, and vary on the host. Similar to Annotation, the host indicates who logged the event. This allows you to tell the difference between the client and server side of the same key. For example, the key "http.uri" might be different on the client and server side due to rewriting, like "/api/v1/myresource" vs "/myresource. Via the host field, you can see the different points of view, which often help in debugging.

  4. object ClientId extends ThriftStructCodec3[ClientId] with Serializable

    At connection time, we can let the server know who we are so they can book keep and optionally reject unknown clients.

  5. object ConnectionOptions extends ThriftStructCodec3[ConnectionOptions] with Serializable

    These are connection-level options negotiated during protocol upgrade.

  6. object Constants
    Annotations
    @Generated()
  7. object Delegation extends ThriftStructCodec3[Delegation] with Serializable

    Serializes an individual delegation.

  8. object Endpoint extends ThriftStructCodec3[Endpoint] with Serializable

    Indicates the network context of a service recording an annotation with two exceptions.

    Indicates the network context of a service recording an annotation with two exceptions.

    When a BinaryAnnotation, and key is CLIENT_ADDR or SERVER_ADDR, the endpoint indicates the source or destination of an RPC. This exception allows zipkin to display network context of uninstrumented services, or clients such as web browsers.

  9. object RequestContext extends ThriftStructCodec3[RequestContext] with Serializable

    This struct serializes com.twitter.finagle.Context

  10. object RequestHeader extends ThriftStructCodec3[RequestHeader] with Serializable

    RequestHeader defines headers for the request.

    RequestHeader defines headers for the request. These carry the span data, and a flag indicating whether the request is to be debugged.

  11. object ResponseHeader extends ThriftStructCodec3[ResponseHeader] with Serializable

    The Response carries a reply header for tracing.

    The Response carries a reply header for tracing. These are empty unless the request is being debugged, in which case a transcript is copied.

  12. object Span extends ThriftStructCodec3[Span] with Serializable

    A trace is a series of spans (often RPC calls) which form a latency tree.

    A trace is a series of spans (often RPC calls) which form a latency tree.

    The root span is where trace_id = id and parent_id = Nil. The root span is usually the longest interval in the trace, starting with a SERVER_RECV annotation and ending with a SERVER_SEND.

  13. object UpgradeReply extends ThriftStructCodec3[UpgradeReply] with Serializable

    This is the struct that a successful upgrade will reply with.

Ungrouped