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.

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
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final val MinGrace: Duration

    Minimum duration to allow for exits to be processed.

  5. def allowUndefinedFlags: Boolean

    Whether or not to accept undefined flags

    Whether or not to accept undefined flags

    Attributes
    protected
  6. def args: Array[String]

    The remaining, unparsed arguments

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def close(deadline: Time): Future[Unit]

    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]
    Definition Classes
    Closable
  11. final def close(): Future[Unit]
    Definition Classes
    Closable
  12. def closeAwaitably(f: ⇒ Future[Unit]): Future[Unit]
    Attributes
    protected
    Definition Classes
    CloseAwaitably0
  13. final def closeOnExit(closable: Closable): Unit

    Close closable when shutdown is requested.

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

    Attributes
    protected
  14. def defaultCloseGracePeriod: Duration

    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
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  17. def exitOnError(reason: String): Unit
    Attributes
    protected
  18. def failfastOnFlagsNotParsed: Boolean

    Users of this code should override this to true so that you fail-fast instead of being surprised at runtime by code that is reading from flags before they have been parsed.

    Users of this code should override this to true so that you fail-fast instead of being surprised at runtime by code that is reading from flags before they have been parsed.

    Ideally this would default to true, however, in order to avoid breaking existing users, it was introduced using false.

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

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

  21. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  23. final def init(f: ⇒ Unit): Unit

    Invoke f before anything else (including flag parsing).

    Invoke f before anything else (including flag parsing).

    Attributes
    protected
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. def isReady(implicit permit: CanAwait): Boolean
    Definition Classes
    CloseAwaitably0 → Awaitable
  26. final def main(args: Array[String]): Unit
  27. val name: String

    The name of the application, based on the classname

  28. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. final def nonExitingMain(args: Array[String]): Unit
  30. final def notify(): Unit
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  32. final def onExit(f: ⇒ Unit): Unit

    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

    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

    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
    Definition Classes
    CloseAwaitably0 → Awaitable
  36. def result(timeout: Duration)(implicit permit: CanAwait): Unit
    Definition Classes
    CloseAwaitably0 → Awaitable
  37. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  38. def toString(): String
    Definition Classes
    AnyRef → Any
  39. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long): Unit
    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