package server
Twitter Server
Provides a common configuration setup for internal Twitter servers based on com.twitter.app.App.
An HTTP server is bound to a configurable port (default: 9900) to which commands can be sent and information queried. Additional handlers can be provided by adding them to com.twitter.finagle.http.HttpMuxer.
object MyServer extends TwitterServer { def main() { // start my service } }
Provided handlers
See com.twitter.server.TwitterServer
Configuration
The default port is set via defaultAdminPort. This can be overridden in the super class or set on the command line with -admin.port.
- Alphabetic
- By Inheritance
- server
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract class AbstractTwitterServer extends TwitterServer
A Java-friendly version of the TwitterServer.
A Java-friendly version of the TwitterServer.
In addition to TwitterServer, this abstract class defines its own Java-friendly lifecycle methods
onInit,preMain,postMainandonExitthat might be overridden in a concrete class.In order to launch the
AbstractTwitterServerinstance, themainmethod should be explicitly defined. It makes sense to define it within an inner classMainas shown below.public class JavaServer extends AbstractTwitterServer { public static class Main { public static void main(String[] args) { new JavaServer().main(args); } } }
The
Mainclass containing themainmethod may be launched viajava JavaServer$Main. - trait AdminHttpServer extends AnyRef
- class FlagAnnouncer extends Announcer
- class FlagResolver extends Resolver
- abstract class Hook extends AnyRef
Defines a hook into an com.twitter.app.App.
- trait Hooks extends AnyRef
Mix-in to include service-loaded hooks.
- trait Lifecycle extends AnyRef
- trait Linters extends AnyRef
Registers any global linter rules.
- class NamedResolverNotFoundException extends Exception
Indicates that a com.twitter.finagle.Resolver was not found for the given
nameusing the FlagResolver.Indicates that a com.twitter.finagle.Resolver was not found for the given
nameusing the FlagResolver.Resolvers are discovered via the com.twitter.server.resolverMap
- trait NewHook extends (App) => Hook
Create a new hook for the given App.
Create a new hook for the given App. NewHooks are service-loaded.
To use, extend the NewHook trait and implement an apply method which returns a Hook implementation, e.g.,
Add the Hook as a service-loaded class in /META-INF/services/com.twitter.server.NewHook
class MyHook extends NewHook { def apply(app: App) = new Hook { override def premain(): Unit = ??? override def onExit(): Unit = ??? } }
- See also
com.twitter.finagle.util.LoadService
- trait Stats extends AnyRef
- trait TwitterServer extends App with Slf4jBridge with Logging with Stats with Linters with DtabFlags with Hooks with AdminHttpServer with Lifecycle
Twitter Server defines a template from which servers at Twitter are built.
Twitter Server defines a template from which servers at Twitter are built. It provides common application components such as an administrative HTTP server, tracing, stats, etc. These features are wired in correctly for use in production at Twitter.
For DI (Dependency Injection) Twitter Server uses self-typed Scala traits that might be mixed in the
TwitterServertrait. The common practice is to define self-typed traits against the App trait as shown below.import com.twitter.app.App import com.twitter.server.TwitterServer trait MyModule { self: App => // module logic } object MyApp extends TwitterServer with MyModule { // app logic }
Note: the Slf4jBridge trait MUST be defined first to properly bridge legacy logging APIs.
Value Members
- object Admin
- object AdminHttpServer
- object Lifecycle
- object announcerMap extends GlobalFlag[Map[String, String]]
- object promoteBeforeServing extends GlobalFlag[Boolean]
Deprecated Value Members
- object resolverMap extends GlobalFlag[Map[String, String]]
- Annotations
- @deprecated
- Deprecated
(Since version 2019-04-03) Users should prefer using Dtabs which are overridable by setting the
dtab.addflag