Understanding the Codebase

Finatra is divided into three main parts: inject, http, and thrift. The inject part of the framework contains all of the base functionality for integration of the Guice dependency injection framework with the TwitterUtil util-app App and the TwitterServer c.t.server.TwitterServer.

Modules in the inject portion of the Finatra framework constitute the core of the framework, are in the com.twitter.inject package namespace, and only depend on each other or outside dependencies (except in testing). The inject layer can be thought of as dealing with concerns that are common to the framework or that span both http and thrift services.

Everything else in the Finatra codebase is in the com.twitter.finatra package namespace and has dependencies on the inject libraries as well as other libraries.

Inject

Modules in inject include:

  • inject-core - core library which defines the TwitterModule, Injector, and the framework TwitterModuleFlags for defining injectable TwitterUtil Flags.
  • inject-modules - core library which defines framework modules.
  • inject-app - core integration with c.t.app.App
  • inject-server - core integration with c.t.server.TwitterServer.
  • inject-slf4j - core library integration with the SLF4J API. Also provides support for bridging Logback’s Mapped Diagnostic Context with Finagle. See Mapped Diagnostic Context Filter Logback documentation for more information.
  • inject-request-scope - core library for integrating Guice‘s Request Scope with TwitterUtil c.t.util.Future. See the Request Scope section for more information.
  • inject-thrift - core library for thrift utilities useful for both clients and server.
  • inject-thrift-client - core library for supporting creation of a Thrift Finagle Client.
  • inject-utils - core library which provides a collection of useful utilities, including implicit conversions, exceptions and futures handling and retries.

Creating an injectable App or TwitterServer

See: Building an injectable c.t.app.App or Building an injectable c.t.server.TwitterServer.

Important

It is important to remember that the Finatra framework establishes an order of the lifecycle of an application or server. See the Application and Server Lifecycle section for more information.

Jackson

Finatra’s integration with jackson-module-scala for JSON support. See the Jackson Integration section for more details.

HttpClient

A simple and barebones Finagle Client for making HTTP requests.

HTTP

Base library for HTTP services. See the HTTP Server Definition section for more information.

Thrift

Base library for Thrift services. See the Thrift Basics and Thrift Server Definition sections for more details.

Utils

A collection of framework utilities that are specifically useful in HTTP or Thrift.

Other

  • inject-thrift-client-http-mapper - a library which bridges inject-thrift-client and http libraries to provide an exception mapper for mapping thrift exceptions to HTTP responses.