Trait/Object

com.twitter.app

App

Related Docs: object App | package app

Permalink

trait App extends Closable with CloseAwaitably

A composable application trait that includes flag parsing as well as basic application lifecycle (pre- and post- main). Flag parsing is done via com.twitter.app.Flags, an instance of which is defined in the member flag. Applications should be constructed with modularity in mind, and common functionality should be extracted into mixins.

Flags should only be constructed in the constructor, and should only be read in the premain or later, after they have been parsed.

object MyApp extends App {
  val n = flag("n", 100, "Number of items to process")

  def main() {
    for (i <- 0 until n()) process(i)
  }
}

Note that a missing main is OK: mixins may provide behavior that does not require defining a custom main method.

Linear Supertypes
CloseAwaitably, CloseAwaitably0[Unit], Awaitable[Unit], Closable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. App
  2. CloseAwaitably
  3. CloseAwaitably0
  4. Awaitable
  5. Closable
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final val MinGrace: Duration

    Permalink

    Minimum duration to allow for exits to be processed.

  5. def allowUndefinedFlags: Boolean

    Permalink

    Whether or not to accept undefined flags

    Whether or not to accept undefined flags

    Attributes
    protected
  6. def args: Array[String]

    Permalink

    The remaining, unparsed arguments

  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def close(deadline: Time): Future[Unit]

    Permalink

    Notify the application that it may stop running.

    Notify the application that it may stop running. Returns a Future that is satisfied when the App has been torn down or errors at the deadline.

    Definition Classes
    App → Closable
  10. def close(after: Duration): Future[Unit]

    Permalink
    Definition Classes
    Closable
  11. final def close(): Future[Unit]

    Permalink
    Definition Classes
    Closable
  12. def closeAwaitably(f: ⇒ Future[Unit]): Future[Unit]

    Permalink
    Attributes
    protected
    Definition Classes
    CloseAwaitably0
  13. final def closeOnExit(closable: Closable): Unit

    Permalink

    Close closable when shutdown is requested.

    Close closable when shutdown is requested. Closables are closed in parallel.

    Attributes
    protected
  14. def defaultCloseGracePeriod: Duration

    Permalink

    Default amount of time to wait for shutdown.

    Default amount of time to wait for shutdown. This value is not used as a default if close() is called without parameters. It simply provides a default value to be passed as close(grace).

  15. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  17. def exitOnError(reason: String): Unit

    Permalink
    Attributes
    protected
  18. def failfastOnFlagsNotParsed: Boolean

    Permalink
    Attributes
    protected
  19. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. val flag: Flags

    Permalink

    The com.twitter.app.Flags instance associated with this application

  21. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  23. final def init(f: ⇒ Unit): Unit

    Permalink

    Invoke f before anything else (including flag parsing).

    Invoke f before anything else (including flag parsing).

    Attributes
    protected
  24. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  25. def isReady(implicit permit: CanAwait): Boolean

    Permalink
    Definition Classes
    CloseAwaitably0 → Awaitable
  26. final def main(args: Array[String]): Unit

    Permalink
  27. val name: String

    Permalink

    The name of the application, based on the classname

  28. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  29. final def nonExitingMain(args: Array[String]): Unit

    Permalink
  30. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. final def onExit(f: ⇒ Unit): Unit

    Permalink

    Invoke f when shutdown is requested.

    Invoke f when shutdown is requested. Exit hooks run in parallel and are executed after all postmains complete. The thread resumes when all exit hooks complete or closeDeadline expires.

    Attributes
    protected
  33. final def postmain(f: ⇒ Unit): Unit

    Permalink

    Invoke f after the user's main has exited.

    Invoke f after the user's main has exited.

    Attributes
    protected
  34. final def premain(f: ⇒ Unit): Unit

    Permalink

    Invoke f right before the user's main is invoked.

    Invoke f right before the user's main is invoked.

    Attributes
    protected
  35. def ready(timeout: Duration)(implicit permit: CanAwait): App.this.type

    Permalink
    Definition Classes
    CloseAwaitably0 → Awaitable
  36. def result(timeout: Duration)(implicit permit: CanAwait): Unit

    Permalink
    Definition Classes
    CloseAwaitably0 → Awaitable
  37. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  38. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  39. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from CloseAwaitably

Inherited from CloseAwaitably0[Unit]

Inherited from Awaitable[Unit]

Inherited from Closable

Inherited from AnyRef

Inherited from Any

Ungrouped