Packages

t

com.twitter.inject.modules

StackClientModuleTrait

trait StackClientModuleTrait[Req, Rep, ClientType <: StackBasedClient[Req, Rep] with Parameterized[ClientType] with CommonParams[ClientType] with ClientParams[ClientType] with WithClientSession[ClientType]] extends TwitterModule

A module for configuring a Finagle StackBasedClient. Binding is explicitly not handled by this trait and implementors are responsible for managing their own binding annotations.

Example:
  1. abstract class MyClientModule
      extends StackClientModuleTrait[Request, Response, MyClient] {
    
      override protected final def baseClient: MyClient = MyClient.client
      override protected def sessionAcquisitionTimeout: Duration = 1.seconds
      override protected def requestTimeout: Duration = 5.seconds
      override protected def retryBudget: RetryBudget = RetryBudget(15.seconds, 5, .1)
    
      // if you want to customize the client configuration
      // you can:
      //
      // override def configureClient(injector: Injector, client: MyClient): MyClient =
      //   client.
      //     withTracer(NullTracer)
      //     withStatsReceiver(NullStatsReceiver)
      //
      // depending on your client type, you may want to provide a global instance,
      // otherwise you might want to specify how your consumers can provide a binding
      // for an instance to the client
      //
      // ex:
      // @Provides
      // @Singleton
      // final def provideMyClient(
      //   injector: Injector,
      //   statsReceiver: StatsReceiver
      //  ): MyClient =
      //    newClient(injector, statsReceiver)
      //
      // Or create a service directly
      //
      // ex:
      // @Provides
      // @Singleton
      // final def provideMyService(
      //   injector: Injector,
      //   statsReceiver: StatsReceiver
      // ): Service[Request, Response] =
      //     myCoolFilter.andThen(newService(injector, statsReceiver))
    }
Note

Extending this module for HTTP and ThriftMux clients should not be necessary, as there are fully supported modules for creating those clients.

,

The ordering of client configuration may be important. The underlying clients will be configured and created in the following order: baseClient -> initialClientConfiguration -> configureClient -> frameworkConfigureClient

Linear Supertypes
TwitterModule, TwitterBaseModule, TwitterModuleLifecycle, Logging, util.logging.Logging, TwitterModuleFlags, AbstractModule, Module, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StackClientModuleTrait
  2. TwitterModule
  3. TwitterBaseModule
  4. TwitterModuleLifecycle
  5. Logging
  6. Logging
  7. TwitterModuleFlags
  8. AbstractModule
  9. Module
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def baseClient: ClientType

    Create a base Finagle Stack Client of type ClientType.

    Create a base Finagle Stack Client of type ClientType. This method should not try to do any configuration on the created client.

    returns

    The base ClientType client, without any custom configuration.

    Attributes
    protected
    Examples:
    1. override def createBaseClient(): Http.Client = Http.client
    2. ,
    3. override def createBaseClient(): ThriftMux.Client = ThriftMux.client
    4. ,
    5. override def createBaseClient(): Memcached.Client =  Memcached.client
  2. abstract def dest: String

    Destination of Finagle client.

    Destination of Finagle client.

    See also

    Names and Naming in Finagle

  3. abstract def label: String

    Finagle client label.

    Finagle client label.

    See also

    Clients Observability

Concrete 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. def addError(arg0: Message): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  5. def addError(arg0: Throwable): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  6. def addError(arg0: String, arg1: <repeated...>[AnyRef]): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
    Annotations
    @transient()
  7. def addTypeConverter[T](converter: TypeConverter)(implicit arg0: Manifest[T]): Unit
    Attributes
    protected
    Definition Classes
    TwitterModule
  8. def asClosable(client: ClientType): Closable

    This method should be overridden by implementors IF the ClientType does not extend Closable.

    This method should be overridden by implementors IF the ClientType does not extend Closable. This method should wrap an underlying client as a Closable to ensure that resources are dealt with cleanly upon shutdown.

    client

    The client that does not extend Closable

    returns

    The Closable whose logic cleans up client's resources

    Attributes
    protected
    Examples:
    1. override protected def asClosable(client: ClientType): Closable =
        clientType.asClosable
    2. ,
    3. override protected def asClosable(client: ClientType): Closable =
        Closable.make { deadline =>
          // Use a FuturePool to ensure the task is completed asynchronously
          // and allow for enforcing the deadline Time.
          FuturePool
            .unboundedPool {
              clientType.closeSession() // clean-up resources
            }.by(deadline)(DefaultTimer)
        }
  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def bind[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaAnnotatedBindingBuilder[T]
    Attributes
    protected
    Definition Classes
    TwitterModule
  11. def bind[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]
    Attributes
    protected
    Definition Classes
    TwitterModule
  12. def bind[T](implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]
    Attributes
    protected
    Definition Classes
    TwitterModule
  13. def bind[T](arg0: Class[T]): AnnotatedBindingBuilder[T]
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  14. def bind[T](arg0: TypeLiteral[T]): AnnotatedBindingBuilder[T]
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  15. def bind[T](arg0: Key[T]): LinkedBindingBuilder[T]
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  16. def bindAssistedFactory[T]()(implicit arg0: Manifest[T]): Unit
    Attributes
    protected
    Definition Classes
    TwitterModule
  17. def bindConstant(): AnnotatedConstantBindingBuilder
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  18. def bindInterceptor(arg0: Matcher[_ >: Class[_]], arg1: Matcher[_ >: Method], arg2: <repeated...>[MethodInterceptor]): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
    Annotations
    @transient()
  19. def bindListener(arg0: Matcher[_ >: Binding[_]], arg1: <repeated...>[ProvisionListener]): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
    Annotations
    @transient()
  20. def bindListener(arg0: Matcher[_ >: TypeLiteral[_]], arg1: TypeListener): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  21. def bindScope(arg0: Class[_ <: Annotation], arg1: Scope): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  22. def bindSingleton[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaAnnotatedBindingBuilder[T]
    Attributes
    protected
    Definition Classes
    TwitterModule
  23. def bindSingleton[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]
    Attributes
    protected
    Definition Classes
    TwitterModule
  24. def bindSingleton[T](implicit arg0: Manifest[T]): ScalaAnnotatedBindingBuilder[T]
    Attributes
    protected
    Definition Classes
    TwitterModule
  25. def binder(): Binder
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  26. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  27. def closeOnExit(f: ⇒ Unit): Unit
    Attributes
    protected
    Definition Classes
    TwitterModuleLifecycle
  28. def configure(): Unit
    Attributes
    protected
    Definition Classes
    TwitterModule → AbstractModule
  29. final def configure(arg0: Binder): Unit
    Definition Classes
    AbstractModule → Module
  30. def configureClient(injector: Injector, client: ClientType): ClientType

    This method allows for further configuration of the ClientType client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,

    This method allows for further configuration of the ClientType client for parameters not exposed by this module or for overriding defaults provided herein, e.g.,

    override protected def configureClient(client: Example.Client): Example.Client = {
      client
        .withStatsReceiver(someOtherScopedStatsReceiver)
        .withMonitor(myAwesomeMonitor)
        .withTracer(notTheDefaultTracer)
    }
    injector

    the com.twitter.inject.Injector which can be used to help configure the given ClientType client.

    client

    the ClientType client to configure.

    returns

    a configured ClientType client.

    Attributes
    protected
  31. def convertToTypes(arg0: Matcher[_ >: TypeLiteral[_]], arg1: TypeConverter): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  32. def createFlag[T](name: String, default: T, help: String, flaggable: Flaggable[T]): Flag[T]
    Attributes
    protected
    Definition Classes
    TwitterModuleFlags
  33. def createKey[T](implicit arg0: Manifest[T]): Key[T]
    Attributes
    protected
    Definition Classes
    TwitterBaseModule
  34. def createMandatoryFlag[T](name: String, help: String, usage: String, flaggable: Flaggable[T]): Flag[T]
    Definition Classes
    TwitterModuleFlags
  35. def createMultiBinder[MultiBindType](implicit arg0: Manifest[MultiBindType]): ScalaMultibinder[MultiBindType]
    Attributes
    protected
    Definition Classes
    TwitterModule
  36. def currentStage(): Stage
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  37. def debug(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  38. def debug(message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  39. def debug(marker: Marker, message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  40. def debug(message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  41. def debugFutureResult[T](msg: String)(func: ⇒ Future[T]): Future[T]
    Attributes
    protected
    Definition Classes
    Logging
  42. def debugResult[T](message: ⇒ String)(fn: ⇒ T): T
    Attributes
    protected[this]
    Definition Classes
    Logging
  43. def defaultClosableAwaitPeriod: Duration

    Default amount of time to block in Duration) on a Closable to close that is registered in a closeOnExit block.

    Default amount of time to block in Duration) on a Closable to close that is registered in a closeOnExit block.

    returns

    a com.twitter.util.Duration

    Attributes
    protected
    See also

    Duration)

  44. def defaultClosableGracePeriod: Duration

    Default amount of time to wait for any Closable being registered in a closeOnExit block.

    Default amount of time to wait for any Closable being registered in a closeOnExit block. Note that this timeout is advisory, as it attempts to give the close function some leeway, for example to drain clients or finish up other tasks.

    returns

    a com.twitter.util.Duration

    Attributes
    protected
    See also

    Duration)

  45. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  46. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  47. def error(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  48. def error(message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  49. def error(marker: Marker, message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  50. def error(message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  51. def errorResult[T](message: ⇒ String)(fn: ⇒ T): T
    Attributes
    protected[this]
    Definition Classes
    Logging
  52. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  53. def flag[T](name: String, help: String)(implicit arg0: Flaggable[T], arg1: Manifest[T]): Flag[T]
    Attributes
    protected
    Definition Classes
    TwitterModuleFlags
  54. def flag[T](name: String, default: T, help: String)(implicit arg0: Flaggable[T]): Flag[T]
    Attributes
    protected
    Definition Classes
    TwitterModuleFlags
  55. val flags: ArrayBuffer[Flag[_]]
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleFlags
  56. def frameworkConfigureClient(injector: Injector, client: ClientType): ClientType
    Attributes
    protected[com.twitter]
  57. def frameworkModules: Seq[Module]
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterBaseModule
  58. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  59. def getMembersInjector[T](arg0: TypeLiteral[T]): MembersInjector[T]
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  60. def getMembersInjector[T](arg0: Class[T]): MembersInjector[T]
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  61. def getProvider[T](implicit arg0: Manifest[T]): Provider[T]
    Attributes
    protected
    Definition Classes
    TwitterModule
  62. def getProvider[T](arg0: Class[T]): Provider[T]
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  63. def getProvider[T](arg0: Key[T]): Provider[T]
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  64. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  65. def info(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  66. def info(message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  67. def info(marker: Marker, message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  68. def info(message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  69. def infoResult[T](message: ⇒ String)(fn: ⇒ T): T
    Attributes
    protected[this]
    Definition Classes
    Logging
  70. def initialClientConfiguration(injector: Injector, client: ClientType, statsReceiver: StatsReceiver): ClientType

    Initial configuration of the underlying client.

    Initial configuration of the underlying client. This is exposed to allow for customization of the base client configuration. All user facing extensions should be done via configureClient.

    returns

    The base configured ClientType client, without any custom end-user configuration.

    Attributes
    protected
    Example:
    1. override protected final def initialClientConfiguration(
        injector: Injector,
        client: ClientType,
        statsReceiver: StatsReceiver
      ): ThriftMux.Client =
        super.initialClientConfiguration(injector, client, statsReceiver)
          .withClientId(injector.instance[ClientId]
  71. def install(module: Module): Unit
    Attributes
    protected
    Definition Classes
    TwitterModule → AbstractModule
  72. def isDebugEnabled(marker: Marker): Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  73. def isDebugEnabled: Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  74. def isErrorEnabled(marker: Marker): Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  75. def isErrorEnabled: Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  76. def isInfoEnabled(marker: Marker): Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  77. def isInfoEnabled: Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  78. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  79. def isTraceEnabled(marker: Marker): Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  80. def isTraceEnabled: Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  81. def isWarnEnabled(marker: Marker): Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  82. def isWarnEnabled: Boolean
    Attributes
    protected[this]
    Definition Classes
    Logging
  83. def javaModules: Collection[Module]
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterBaseModule
  84. final def logger: Logger
    Attributes
    protected[this]
    Definition Classes
    Logging
  85. final def loggerName: String
    Attributes
    protected[this]
    Definition Classes
    Logging
  86. def modules: Seq[Module]
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterBaseModule
  87. def monitor: Monitor

    Function to add a user-defined Monitor.

    Function to add a user-defined Monitor. A com.twitter.finagle.util.DefaultMonitor will be installed implicitly which handles all exceptions caught in the stack. Exceptions that are not handled by a user-defined monitor are propagated to the com.twitter.finagle.util.DefaultMonitor.

    NullMonitor has no influence on DefaultMonitor behavior here.

    Attributes
    protected
  88. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  89. final def newClient(injector: Injector, statsReceiver: StatsReceiver): ClientType

    This method will generate a fully configured ClientType

    This method will generate a fully configured ClientType

    injector

    the com.twitter.inject.Injector which can be used to help configure the given ClientType client.

    statsReceiver

    The StatsReceiver to use with the generated ClientType

    returns

    A configured ClientType

    Attributes
    protected
  90. final def newService(injector: Injector, statsReceiver: StatsReceiver): Service[Req, Rep]

    This method will generate a Service[Req, Rep] from the configured ClientType generated by calling newClient().

    This method will generate a Service[Req, Rep] from the configured ClientType generated by calling newClient().

    injector

    the com.twitter.inject.Injector which can be used to help configure the given ClientType client.

    statsReceiver

    The StatsReceiver to use with the generated Service[Req, Rep].

    returns

    A Service[Req, Rep] that overlays the ClientType

    Attributes
    protected
  91. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  92. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  93. def requestInjection(arg0: Any): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  94. def requestStaticInjection(arg0: <repeated...>[Class[_]]): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
    Annotations
    @transient()
  95. def requestTimeout: Duration

    Configures a "global" request timeout on the Finagle client (default: unbounded).

    Configures a "global" request timeout on the Finagle client (default: unbounded). This will set *all* requests to *every* method to have the same total timeout.

    returns

    a Duration which represents the total request timeout

    Attributes
    protected
    See also

    com.twitter.finagle.param.CommonParams.withRequestTimeout

    https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration

  96. def requireBinding(arg0: Class[_]): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  97. def requireBinding(arg0: Key[_]): Unit
    Attributes
    protected[com.google.inject]
    Definition Classes
    AbstractModule
  98. def retryBudget: RetryBudget

    Default com.twitter.finagle.service.RetryBudget.

    Default com.twitter.finagle.service.RetryBudget. It is highly recommended that budgets be shared between all filters that retry or re-queue requests to prevent retry storms.

    returns

    a default com.twitter.finagle.service.RetryBudget

    Attributes
    protected
    See also

    https://twitter.github.io/finagle/guide/Clients.html#retries

  99. def sessionAcquisitionTimeout: Duration

    Configures the session acquisition timeout of this client (default: unbounded).

    Configures the session acquisition timeout of this client (default: unbounded).

    returns

    a Duration which represents the acquisition timeout

    Attributes
    protected
    See also

    com.twitter.finagle.param.ClientSessionParams.acquisitionTimeout

    https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration

  100. def singletonPostWarmupComplete(injector: Injector): Unit
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleLifecycle
  101. def singletonShutdown(injector: Injector): Unit
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleLifecycle
  102. def singletonStartup(injector: Injector): Unit
    Attributes
    protected[com.twitter.inject]
    Definition Classes
    TwitterModuleLifecycle
  103. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  104. def time[T](formatStr: String)(func: ⇒ T): T
    Attributes
    protected
    Definition Classes
    Logging
  105. def toString(): String
    Definition Classes
    AnyRef → Any
  106. def trace(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  107. def trace(message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  108. def trace(marker: Marker, message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  109. def trace(message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  110. def traceResult[T](message: ⇒ String)(fn: ⇒ T): T
    Attributes
    protected[this]
    Definition Classes
    Logging
  111. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  112. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  113. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  114. def warn(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  115. def warn(message: ⇒ Any, cause: Throwable): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  116. def warn(marker: Marker, message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  117. def warn(message: ⇒ Any): Unit
    Attributes
    protected[this]
    Definition Classes
    Logging
  118. def warnResult[T](message: ⇒ String)(fn: ⇒ T): T
    Attributes
    protected[this]
    Definition Classes
    Logging

Inherited from TwitterModule

Inherited from TwitterBaseModule

Inherited from TwitterModuleLifecycle

Inherited from Logging

Inherited from util.logging.Logging

Inherited from TwitterModuleFlags

Inherited from AbstractModule

Inherited from Module

Inherited from AnyRef

Inherited from Any

Ungrouped