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.
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
- Alphabetic
- By Inheritance
- StackClientModuleTrait
- TwitterModule
- ScalaModule
- InternalModule
- TwitterBaseModule
- TwitterModuleLifecycle
- Logging
- TwitterModuleFlags
- AbstractModule
- Module
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
BindingBuilder[T] extends ScalaAnnotatedBindingBuilder[T]
- Definition Classes
- InternalModule
Abstract Value Members
-
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
override def createBaseClient(): Http.Client = Http.client
, override def createBaseClient(): ThriftMux.Client = ThriftMux.client
, override def createBaseClient(): Memcached.Client = Memcached.client
Examples: -
abstract
def
dest: String
Destination of Finagle client.
Destination of Finagle client.
- See also
-
abstract
def
label: String
Finagle client label.
Finagle client label.
- See also
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
addError(arg0: Message): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
addError(arg0: Throwable): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
addError(arg0: String, arg1: <repeated...>[AnyRef]): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
- Annotations
- @transient()
-
def
addFlagConverter[T <: AnyRef](typeMatcher: Matcher[_ >: TypeLiteral[_]], F: Flaggable[T]): Unit
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
addFlagConverter[T <: AnyRef](implicit arg0: Manifest[T], F: Flaggable[T]): Unit
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
addTypeConverter[T](converter: TypeConverter)(implicit arg0: Manifest[T]): Unit
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
annotatedWith[A <: Annotation](implicit arg0: ClassTag[A]): Matcher[AnnotatedElement]
- Attributes
- protected[this]
- Definition Classes
- InternalModule
-
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
override protected def asClosable(client: ClientType): Closable = clientType.asClosable
, 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) }
Examples: -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bind[T](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): BindingBuilder[T]
- Attributes
- protected[this]
- Definition Classes
- InternalModule
-
def
bind[T](arg0: Class[T]): AnnotatedBindingBuilder[T]
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
bind[T](arg0: TypeLiteral[T]): AnnotatedBindingBuilder[T]
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
bind[T](arg0: Key[T]): LinkedBindingBuilder[T]
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
bindAssistedFactory[T]()(implicit arg0: Manifest[T]): Unit
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
bindConstant(): AnnotatedConstantBindingBuilder
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
bindInterceptor[I <: MethodInterceptor](classMatcher: Matcher[_ >: Class[_]], methodMatcher: Matcher[_ >: AnnotatedElement])(implicit arg0: ClassTag[I]): Unit
- Attributes
- protected[this]
- Definition Classes
- InternalModule
-
def
bindInterceptor(arg0: Matcher[_ >: Class[_]], arg1: Matcher[_ >: Method], arg2: <repeated...>[MethodInterceptor]): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
- Annotations
- @transient()
-
def
bindListener(arg0: Matcher[_ >: Binding[_]], arg1: <repeated...>[ProvisionListener]): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
- Annotations
- @transient()
-
def
bindListener(arg0: Matcher[_ >: TypeLiteral[_]], arg1: TypeListener): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
bindMultiple[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaMultibinder[T]
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
bindMultiple[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaMultibinder[T]
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
bindMultiple[T](implicit arg0: Manifest[T]): ScalaMultibinder[T]
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
bindOption[T](annotation: Annotation)(implicit arg0: Manifest[T]): ScalaOptionBinder[T]
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
bindOption[T, A <: Annotation](implicit arg0: Manifest[T], arg1: Manifest[A]): ScalaOptionBinder[T]
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
bindOption[T](implicit arg0: Manifest[T]): ScalaOptionBinder[T]
- Attributes
- protected
- Definition Classes
- TwitterModule
-
def
bindScope[T <: Annotation](scope: Scope)(implicit arg0: ClassTag[T]): Unit
- Attributes
- protected[this]
- Definition Classes
- InternalModule
-
def
bindScope(arg0: Class[_ <: Annotation], arg1: Scope): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
binder(): Binder
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
binderAccess: Binder
- Attributes
- protected[this]
- Definition Classes
- ScalaModule → InternalModule
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
configure(): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
final
def
configure(arg0: Binder): Unit
- Definition Classes
- AbstractModule → Module
-
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
-
def
convertToTypes(arg0: Matcher[_ >: TypeLiteral[_]], arg1: TypeConverter): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
final
def
createFlag[T](name: String, default: T, help: String, flaggable: Flaggable[T]): Flag[T]
- Definition Classes
- TwitterModuleFlags
-
final
def
createMandatoryFlag[T](name: String, help: String, usage: String, flaggable: Flaggable[T]): Flag[T]
- Definition Classes
- TwitterModuleFlags
-
def
currentStage(): Stage
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
debug(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debug(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
debugResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
defaultClosableAwaitPeriod: Duration
Default amount of time to block in Duration) on a Closable to close that is registered in a
closeOnExitblock.Default amount of time to block in Duration) on a Closable to close that is registered in a
closeOnExitblock.- returns
- Attributes
- protected
- See also
Duration)
-
def
defaultClosableGracePeriod: Duration
Default amount of time to wait for any Closable being registered in a
closeOnExitblock.Default amount of time to wait for any Closable being registered in a
closeOnExitblock. 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
- Attributes
- protected
- See also
Duration)
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
error(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
error(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
errorResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
failfastOnFlagsNotParsed: Boolean
- Attributes
- protected[this]
- Definition Classes
- TwitterModuleFlags
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
flag[T](name: String, help: String)(implicit arg0: Flaggable[T], arg1: Manifest[T]): Flag[T]
- Definition Classes
- TwitterModuleFlags
-
final
def
flag[T](name: String, default: T, help: String)(implicit arg0: Flaggable[T]): Flag[T]
- Definition Classes
- TwitterModuleFlags
-
val
flags: ArrayBuffer[Flag[_]]
- Attributes
- protected[inject]
- Definition Classes
- TwitterModuleFlags
-
def
frameworkConfigureClient(injector: Injector, client: ClientType): ClientType
- Attributes
- protected[twitter]
-
def
frameworkModules: Seq[Module]
- Attributes
- protected[inject]
- Definition Classes
- TwitterBaseModule
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getMembersInjector[T](implicit arg0: scala.reflect.api.JavaUniverse.TypeTag[T]): MembersInjector[T]
- Attributes
- protected[this]
- Definition Classes
- InternalModule
-
def
getMembersInjector[T](arg0: TypeLiteral[T]): MembersInjector[T]
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
getMembersInjector[T](arg0: Class[T]): MembersInjector[T]
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
getProvider[T](implicit arg0: ClassTag[T]): Provider[T]
- Attributes
- protected[this]
- Definition Classes
- InternalModule
-
def
getProvider[T](arg0: Class[T]): Provider[T]
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
getProvider[T](arg0: Key[T]): Provider[T]
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
info(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
info(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
infoResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
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
override protected final def initialClientConfiguration( injector: Injector, client: ClientType, statsReceiver: StatsReceiver ): ThriftMux.Client = super.initialClientConfiguration(injector, client, statsReceiver) .withClientId(injector.instance[ClientId]
Example: -
def
install(module: Module): Unit
- Attributes
- protected
- Definition Classes
- TwitterModule → AbstractModule
- Annotations
- @throws( ... )
-
def
isDebugEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isDebugEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isErrorEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isErrorEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isInfoEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isInfoEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isTraceEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isTraceEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isWarnEnabled(marker: Marker): Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
isWarnEnabled: Boolean
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
javaModules: Collection[Module]
- Attributes
- protected[inject]
- Definition Classes
- TwitterBaseModule
-
final
def
logger: Logger
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
loggerName: String
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
modules: Seq[Module]
- Attributes
- protected[inject]
- Definition Classes
- TwitterBaseModule
-
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
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
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
- Note
The ability to override this method is exposed for Java compatibility purposes, where the type information in this trait can be erased from this trait to a more generic ClientType, which can cause Java compilation failures. See https://issues.scala-lang.org/browse/SI-8905. When overriding this method, it should treat this method as final, outside of providing a more specific return type. For example:
override protected final def newClient( injector: Injector, statsReceiver: StatsReceiver ): Http.Client = super.newClient(injector, statsReceiver)
-
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
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
onExit(f: ⇒ Unit): Unit
- Attributes
- protected
- Definition Classes
- TwitterModuleLifecycle
-
def
requestInjection(arg0: Any): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
requestStaticInjection[T]()(implicit arg0: ClassTag[T]): Unit
- Attributes
- protected[this]
- Definition Classes
- InternalModule
-
def
requestStaticInjection(arg0: <repeated...>[Class[_]]): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
- Annotations
- @transient()
-
def
requestTimeout: Duration
Configures a "global" request
timeouton the Finagle client (default: unbounded).Configures a "global" request
timeouton 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
-
def
requireBinding(arg0: Class[_]): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
def
requireBinding(arg0: Key[_]): Unit
- Attributes
- protected[google.inject]
- Definition Classes
- AbstractModule
-
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
-
def
scopeStatsReceiver(injector: Injector, statsReceiver: StatsReceiver): StatsReceiver
Provide a customized base scope for the StatsReceiver exposed by this module, e.g., * *
Provide a customized base scope for the StatsReceiver exposed by this module, e.g., * *
override protected def scopeStatsReceiver(injector: Injector, statsReceiver: StatsReceiver): StatsReceiver = statsReceiver.scope("clnt", "custom_scope")
- Attributes
- protected
- Note
The default scope is "clnt".
,Changing the default scope can have negative impacts on observability of metrics. Use caution when changing this value.
-
def
sessionAcquisitionTimeout: Duration
Configures the session acquisition
timeoutof this client (default: unbounded).Configures the session acquisition
timeoutof this client (default: unbounded).- returns
a Duration which represents the acquisition timeout
-
def
singletonPostWarmupComplete(injector: Injector): Unit
- Attributes
- protected[inject]
- Definition Classes
- TwitterModuleLifecycle
-
def
singletonShutdown(injector: Injector): Unit
- Attributes
- protected[inject]
- Definition Classes
- TwitterModuleLifecycle
-
def
singletonStartup(injector: Injector): Unit
- Attributes
- protected[inject]
- Definition Classes
- TwitterModuleLifecycle
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
trace(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
trace(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
traceResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
warn(marker: Marker, message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(message: ⇒ Any, cause: Throwable): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(marker: Marker, message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warn(message: ⇒ Any): Unit
- Attributes
- protected[this]
- Definition Classes
- Logging
-
def
warnResult[T](message: ⇒ String)(fn: ⇒ T): T
- Attributes
- protected[this]
- Definition Classes
- Logging