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
  • Annotation
  • AnnotationType
  • BinaryAnnotation
  • ClientId
  • ConnectionOptions
  • Constants
  • Delegation
  • Endpoint
  • RequestContext
  • RequestHeader
  • ResponseHeader
  • Span
  • UpgradeReply
  • package thriftscala
    Definition Classes
    thrift

package thrift

Type Members

  1. class Annotation extends TBase[Annotation, _Fields] with Serializable with Cloneable

    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. sealed abstract final class AnnotationType extends Enum[AnnotationType] with TEnum

    Autogenerated by Thrift

    Autogenerated by Thrift

    DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING

  3. class BinaryAnnotation extends TBase[BinaryAnnotation, _Fields] with Serializable with Cloneable

    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 convert the path to a resource in an RPC call.

    Binary annotations of type STRING are always queryable, though more of 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. class ClientId extends TBase[ClientId, _Fields] with Serializable with Cloneable

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

  5. class ConnectionOptions extends TBase[ConnectionOptions, _Fields] with Serializable with Cloneable

    These are connection-level options negotiated during protocol upgrade.

  6. class Constants extends AnyRef

    Autogenerated by Thrift

    Autogenerated by Thrift

    DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING

  7. class Delegation extends TBase[Delegation, _Fields] with Serializable with Cloneable

    Serializes an individual delegation.

  8. class Endpoint extends TBase[Endpoint, _Fields] with Serializable with Cloneable

    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. class RequestContext extends TBase[RequestContext, _Fields] with Serializable with Cloneable

    This struct serializes com.twitter.finagle.Context

  10. class RequestHeader extends TBase[RequestHeader, _Fields] with Serializable with Cloneable

    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. class ResponseHeader extends TBase[ResponseHeader, _Fields] with Serializable with Cloneable

    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. class Span extends TBase[Span, _Fields] with Serializable with Cloneable

    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. class UpgradeReply extends TBase[UpgradeReply, _Fields] with Serializable with Cloneable

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

Ungrouped