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 addr
    Definition Classes
    finagle
  • package builder
    Definition Classes
    finagle
  • package client
    Definition Classes
    finagle
  • package context
    Definition Classes
    finagle
  • package core
    Definition Classes
    finagle
  • package dispatch
    Definition Classes
    finagle
  • package exp

    Package exp contains experimental code.

    Package exp contains experimental code. This can be removed or stabilized (moved elsewhere) at any time.

    Definition Classes
    finagle
  • package factory
    Definition Classes
    finagle
  • package filter
    Definition Classes
    finagle
  • DtabStatsFilter
  • ExceptionSourceFilter
  • LogFormatter
  • LoggingFilter
  • MaskCancelFilter
  • MkJvmFilter
  • MonitorFilter
  • NackAdmissionFilter
  • RequestLogger
  • RequestMeterFilter
  • RequestSemaphoreFilter
  • package liveness
    Definition Classes
    finagle
  • package loadbalancer

    This package implements client side load balancing algorithms.

    This package implements client side load balancing algorithms.

    As an end-user, see the Balancers API to create instances which can be used to configure a Finagle client with various load balancing strategies.

    As an implementor, each algorithm gets its own subdirectory and is exposed via the Balancers object. Several convenient traits are provided which factor out common behavior and can be mixed in (i.e. Balancer, DistributorT, NodeT, and Updating).

    Definition Classes
    finagle
  • package namer
    Definition Classes
    finagle
  • package naming
    Definition Classes
    finagle
  • package offload
    Definition Classes
    finagle
  • package param

    Defines common com.twitter.finagle.Stack.Param's shared between finagle clients and servers.

    Defines common com.twitter.finagle.Stack.Param's shared between finagle clients and servers.

    Definition Classes
    finagle
  • package pool
    Definition Classes
    finagle
  • package pushsession
    Definition Classes
    finagle
  • package server
    Definition Classes
    finagle
  • package service
    Definition Classes
    finagle
  • package ssl
    Definition Classes
    finagle
  • package stats
    Definition Classes
    finagle
  • package thrift
    Definition Classes
    finagle
  • package tracing
    Definition Classes
    finagle
  • package transport
    Definition Classes
    finagle
  • package util
    Definition Classes
    finagle

package filter

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. class DtabStatsFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    Adds a Stat, dtab/local/size, that tracks the size of Dtab.local for all requests with a non-empty Dtab.

  2. class ExceptionSourceFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    A com.twitter.finagle.Filter that sources exceptions.

    A com.twitter.finagle.Filter that sources exceptions. The serviceName field of any com.twitter.finagle.SourcedException thrown by the underlying com.twitter.finagle.Service is set to the serviceName argument of this filter.

  3. trait LogFormatter[-Req, Rep] extends AnyRef
  4. trait LoggingFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    A com.twitter.finagle.Filter that logs all requests according to formatter.

  5. class MaskCancelFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    A com.twitter.finagle.Filter that prevents cancellations from propagating to any subsequent Services.

    A com.twitter.finagle.Filter that prevents cancellations from propagating to any subsequent Services. i.e. when Future.raise is invoked on the result of this filter's apply method, the interrupt will not be propagated to the service. This is useful for lightweight protocols for which finishing a request is preferable to closing and reesstablishing a connection.

  6. class MkJvmFilter extends AnyRef

    Given a com.twitter.util.Jvm, use apply to create a Filter to trace garbage collection events.

  7. class MonitorFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    A com.twitter.finagle.Filter that handles exceptions (incl.

    A com.twitter.finagle.Filter that handles exceptions (incl. raw) thrown by the subsequent com.twitter.finagle.Service. Exceptions are handled according to the argument com.twitter.util.Monitor.

  8. class NackAdmissionFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    This filter probabilistically drops requests if the nack rate exceeds the nackRateThreshold.

    This filter probabilistically drops requests if the nack rate exceeds the nackRateThreshold. In the case that most or all of the cluster which the client is speaking to is overloaded, this will help the cluster cool off.

    The implementation of this filter is heavily inspired by Chapter 21, section "Client-Side Throttling" of O'Reilly's "Site Reliability Engineering: How Google Runs Production Systems", by Beyer, Jones, Petoff, and Murphy, 1e.

    NOTE: Here is a brief summary of the configurable params.

    A configuration with a nackRateThreshold of N% and a window of duration W roughly translates as, "start dropping some requests to the cluster when the nack rate averages at least N% over a window of duration W."

    Here are some examples of situations with param values chosen to make the filter useful:

    - Owners of Service A examine their service's nack rate over several days and find that it is almost always under 10% and rarely above 1% (e.g., during traffic spikes) or 5% (e.g., during a data center outage). They do not want to preemptively drop requests unless the cluster sees an extreme overload situation so they choose a nack rate threshold of 20%. And in such a situation they want the filter to act relatively quickly, so they choose a window of 30 seconds.

    - Owners of Service B observe that excess load typically causes peak nack rates of around 25% for up to 60 seconds. They want to be aggressive about avoiding cluster overload and don’t mind dropping some innocent requests during mild load so they choose a window of 10 seconds and a threshold of 0.15 (= 15%).

  9. class RequestMeterFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    A com.twitter.finagle.Filter that rate limits requests to a fixed rate over time by using the com.twitter.concurrent.AsyncMeter implementation.

    A com.twitter.finagle.Filter that rate limits requests to a fixed rate over time by using the com.twitter.concurrent.AsyncMeter implementation. It can be used for slowing down access to throttled resources. Requests that cannot be enqueued to await a permit are failed immediately with a com.twitter.finagle.Failure that signals that the work was never done, so it's safe to reenqueue.

    NOTE: If you're just trying not to be overwhelmed, you almost certainly want to use com.twitter.finagle.filter.RequestSemaphoreFilter instead, because RequestMeterFilter doesn't work well with "real" resources that are sometimes faster or slower (like a service that you're depending on that sometimes slows when it takes bursty traffic). This is better for resources that are artificially bounded, like a rate-limited API.

  10. class RequestSemaphoreFilter[Req, Rep] extends SimpleFilter[Req, Rep]

    A com.twitter.finagle.Filter that restricts request concurrency according to the given com.twitter.concurrent.AsyncSemaphore.

    A com.twitter.finagle.Filter that restricts request concurrency according to the given com.twitter.concurrent.AsyncSemaphore. Requests that are unable to acquire a permit are failed immediately with a com.twitter.finagle.Failure that signals a restartable or idempotent process.

Ungrouped