case class Client(stack: Stack[ServiceFactory[Command, Response]] = Client.stack, params: Params = Client.params) extends PushStackClient[Command, Response, Client] with MemcachedRichClient with Product with Serializable
A memcached client with support for pipelined requests, consistent hashing, and per-node load-balancing.
- Alphabetic
- By Inheritance
- Client
- Serializable
- Serializable
- Product
- Equals
- MemcachedRichClient
- PushStackClient
- EndpointerStackClient
- WithSessionQualifier
- WithClientSession
- WithClientTransport
- WithClientAdmissionControl
- ClientParams
- CommonParams
- StackClient
- StackBasedClient
- Transformable
- Parameterized
- Client
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Client(stack: Stack[ServiceFactory[Command, Response]] = Client.stack, params: Params = Client.params)
Type Members
-
type
In = Response
Type of the messages which will be received from the transporter level by the PushSession.
Type of the messages which will be received from the transporter level by the PushSession.
- Attributes
- protected
- Definition Classes
- Client → PushStackClient
-
type
Out = Command
Type of messages which will be written to the transporter level by the PushSession.
Type of messages which will be written to the transporter level by the PushSession.
- Attributes
- protected
- Definition Classes
- Client → PushStackClient
-
type
SessionT = PipeliningClientPushSession[Response, Command]
Refined type of the PushSession.
Refined type of the PushSession.
- Attributes
- protected
- Definition Classes
- Client → PushStackClient
- Note
the type of
SessionT
is significant as it represents the type which willreceive
the inbound events from the handle. It is possible to transition between session implementations in order to handle protocol transitions (e.g. negotiation). For example,newSession
can return the type which will receive the first phase of inbound events andtoService
can transform the type via future composition. In this way, the relationship betweennewSession
andtoService
represent a state machine transition.
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
configured[P](psp: (P, Param[P])): Client
Creates a new StackClient with parameter
psp._1
and Stack Param typepsp._2
.Creates a new StackClient with parameter
psp._1
and Stack Param typepsp._2
.- Definition Classes
- Client → EndpointerStackClient → StackClient → Parameterized
-
def
configured[P](p: P)(implicit arg0: Param[P]): Client
Creates a new StackClient with parameter
p
.Creates a new StackClient with parameter
p
.- Definition Classes
- EndpointerStackClient → StackClient → Parameterized
-
def
configuredParams(newParams: Params): Client
Creates a new StackClient with additional parameters
newParams
.Creates a new StackClient with additional parameters
newParams
.- Definition Classes
- EndpointerStackClient → StackClient → Parameterized
-
def
connectionsPerEndpoint(connections: Int): Client
Configures the number of concurrent
connections
a single endpoint has.Configures the number of concurrent
connections
a single endpoint has. The connections are load balanced over which allows the pipelined client to avoid head-of-line blocking and reduce its latency.We've empirically found that two is a good default for this, but it can be increased at the cost of additional connection overhead.
-
def
copy1(stack: Stack[ServiceFactory[Command, Response]], params: Params): Client
A copy constructor in lieu of defining StackClient as a case class.
A copy constructor in lieu of defining StackClient as a case class.
- Attributes
- protected
- Definition Classes
- Client → PushStackClient → EndpointerStackClient
-
final
def
endpointer: Stackable[ServiceFactory[Command, Response]]
Defines the service factory, which establishes connections to a remote peer on apply and returns a service which can write messages onto the wire and read them off of the wire.
Defines the service factory, which establishes connections to a remote peer on apply and returns a service which can write messages onto the wire and read them off of the wire.
Concrete StackClient implementations are expected to specify this.
- Attributes
- protected
- Definition Classes
- PushStackClient → EndpointerStackClient
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
filtered(filter: Filter[Command, Response, Command, Response]): Client
Prepends
filter
to the top of the client.Prepends
filter
to the top of the client. That is, after materializing the client (newClient/newService)filter
will be the first element which requests flow through. This is a familiar chaining combinator for filters and is particularly useful forStdStackClient
implementations that don't expose services but instead wrap the resulting service with a rich API.- Definition Classes
- Client → EndpointerStackClient
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
newClient(dest: Name, label0: String): ServiceFactory[Command, Response]
Create a new client connected to
dest
.Create a new client connected to
dest
. See the user guide for details on destination names.Argument
label
is used to assign a label to this client. The label is used to display stats, etc.- label0
if an empty String is provided, then the label from the Label Stack.Params is used. If that is also an empty String, then
dest
is used.
- Definition Classes
- EndpointerStackClient → Client
-
final
def
newClient(dest: String, label: String): ServiceFactory[Command, Response]
Create a new client connected to
dest
.Create a new client connected to
dest
. See the user guide for details on destination names.Argument
label
is used to assign a label to this client. The label is used to display stats, etc.- Definition Classes
- Client
-
final
def
newClient(dest: String): ServiceFactory[Command, Response]
Create a new client connected to
dest
.Create a new client connected to
dest
. See the user guide for details on destination names.- Definition Classes
- Client
-
def
newPushTransporter(ia: InetSocketAddress): PushTransporter[Response, Command]
Construct a new PushTransporter with the appropriately configured pipeline.
Construct a new PushTransporter with the appropriately configured pipeline.
- Attributes
- protected
- Definition Classes
- Client → PushStackClient
-
def
newRichClient(dest: String): memcached.Client
Constructs a memcached.Client that dispatches requests over
dest
.Constructs a memcached.Client that dispatches requests over
dest
. Whendest
resolves to multiple hosts, the hosts are hashed across a ring with key affinity. The key hashing algorithm can be configured via thewithKeyHasher
method onMemcached.client
. Failing hosts can be ejected from the hash ring ifwithEjectFailedHost
is set to true. Note, the current implementation only supports bound Names.- Definition Classes
- MemcachedRichClient
-
def
newRichClient(dest: Name, label: String): memcached.Client
Constructs a memcached.Client that dispatches requests over
dest
.Constructs a memcached.Client that dispatches requests over
dest
. Whendest
resolves to multiple hosts, the hosts are hashed across a ring with key affinity. The key hashing algorithm can be configured via thewithKeyHasher
method onMemcached.client
. Failing hosts can be ejected from the hash ring ifwithEjectFailedHost
is set to true. Note, the current implementation only supports bound Names.Argument
label
is used to assign a label to this client. The label is used to scope stats, etc.- Definition Classes
- MemcachedRichClient
-
def
newService(dest: Name, label: String): Service[Command, Response]
Create a new service which dispatches requests to
dest
.Create a new service which dispatches requests to
dest
. See the user guide for details on destination names.Argument
label
is used to assign a label to this client. The label is used to display stats, etc.- Definition Classes
- EndpointerStackClient → Client
-
final
def
newService(dest: String, label: String): Service[Command, Response]
Create a new service which dispatches requests to
dest
.Create a new service which dispatches requests to
dest
. See the user guide for details on destination names.- Definition Classes
- Client
-
final
def
newService(dest: String): Service[Command, Response]
Create a new service which dispatches requests to
dest
.Create a new service which dispatches requests to
dest
. See the user guide for details on destination names.- Definition Classes
- Client
-
def
newSession(handle: PushChannelHandle[Response, Command]): Future[SessionT]
Construct a new push session from the provided PushChannelHandle generated from the PushTransporter
Construct a new push session from the provided PushChannelHandle generated from the PushTransporter
- Attributes
- protected
- Definition Classes
- Client → PushStackClient
-
def
newTwemcacheClient(dest: Name, label: String): TwemcacheClient
Constructs a memcached.Client that dispatches requests over
dest
.Constructs a memcached.Client that dispatches requests over
dest
. Whendest
resolves to multiple hosts, the hosts are hashed across a ring with key affinity. The key hashing algorithm can be configured via thewithKeyHasher
method onMemcached.client
. Failing hosts can be ejected from the hash ring ifwithEjectFailedHost
is set to true. Note, the current implementation only supports bound Names.Argument
label
is used to assign a label to this client. The label is used to scope stats, etc.- Definition Classes
- Client → MemcachedRichClient
-
def
newTwemcacheClient(dest: String): TwemcacheClient
Constructs a memcached.Client that dispatches requests over
dest
.Constructs a memcached.Client that dispatches requests over
dest
. Whendest
resolves to multiple hosts, the hosts are hashed across a ring with key affinity. The key hashing algorithm can be configured via thewithKeyHasher
method onMemcached.client
. Failing hosts can be ejected from the hash ring ifwithEjectFailedHost
is set to true. Note, the current implementation only supports bound Names.- Definition Classes
- MemcachedRichClient
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
val
params: Params
The current parameter map.
The current parameter map.
- Definition Classes
- Client → StackClient → Parameterized
-
final
def
registerTransporter(transporterName: String): Unit
Export info about the transporter type so that we can query info about its implementation at runtime.
Export info about the transporter type so that we can query info about its implementation at runtime.
- Attributes
- protected
- Definition Classes
- StackClient
-
val
stack: Stack[ServiceFactory[Command, Response]]
The current stack.
The current stack.
- Definition Classes
- Client → StackClient
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toService(session: SessionT): Future[Service[Command, Response]]
Build a
Service
from the provided push sessionBuild a
Service
from the provided push session- Attributes
- protected
- Definition Classes
- Client → PushStackClient
-
def
transformed(t: Transformer): StackClient[Command, Response]
- Definition Classes
- StackClient → Transformable
- See also
-
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
- @native() @throws( ... )
-
val
withAdmissionControl: ClientAdmissionControlParams[Client]
An entry point for configuring the clients' admission control
An entry point for configuring the clients' admission control
- Definition Classes
- Client → WithClientAdmissionControl
-
def
withEjectFailedHost(eject: Boolean): Client
Whether to eject cache host from the Ketama ring based on failure accrual.
Whether to eject cache host from the Ketama ring based on failure accrual. By default, this is off. When turning on, keep the following caveat in mind: ejection is based on local failure accrual, so your cluster may get different views of the same cache host. With cache updates, this can introduce inconsistency in cache data. In many cases, it's better to eject cache host from a separate mechanism that's based on a global view.
-
def
withExceptionStatsHandler(exceptionStatsHandler: ExceptionStatsHandler): Client
Configures this server or client with given exception stats handler.
Configures this server or client with given exception stats handler.
- Definition Classes
- Client → CommonParams
-
def
withKeyHasher(hasher: KeyHasher): Client
Defines the hash function to use for partitioned clients when mapping keys to partitions.
-
def
withLabel(label: String): Client
Configures this server or client with given
label
(default: empty string).Configures this server or client with given
label
(default: empty string).The
label
value is used for stats reporting to scope stats reported from different clients/servers to a single stats receiver.- Definition Classes
- Client → CommonParams
-
def
withMonitor(monitor: Monitor): Client
Configures this server or client with given util.Monitor (default: com.twitter.finagle.util.DefaultMonitor).
Configures this server or client with given util.Monitor (default: com.twitter.finagle.util.DefaultMonitor).
- Definition Classes
- Client → CommonParams
-
def
withNumReps(reps: Int): Client
Duplicate each node across the hash ring according to
reps
.Duplicate each node across the hash ring according to
reps
.- See also
com.twitter.hashing.KetamaDistributor for more details.
-
def
withParams(params: Params): Client
Creates a new StackClient with
params
used to configure this StackClient'sstack
.Creates a new StackClient with
params
used to configure this StackClient'sstack
.- Definition Classes
- EndpointerStackClient → StackClient → Parameterized
-
def
withRequestTimeout(timeout: Duration): Client
Configures the request
timeout
of this server or client (default: unbounded).Configures the request
timeout
of this server or client (default: unbounded).If the request has not completed within the given
timeout
, the pending work will be interrupted via com.twitter.util.Future.raise.Client's Request Timeout
The client request timeout is the maximum amount of time given to a single request (if there are retries, they each get a fresh request timeout). The timeout is applied only after a connection has been acquired. That is: it is applied to the interval between the dispatch of the request and the receipt of the response.
Server's Request Timeout
The server request timeout is the maximum amount of time, a server is allowed to spend handling the incoming request. Using the Finagle terminology, this is an amount of time after which a non-satisfied future returned from the user-defined service times out.
- Definition Classes
- Client → CommonParams
- See also
https://twitter.github.io/finagle/guide/Clients.html#timeouts-expiration
-
def
withRequestTimeout(timeout: Tunable[Duration]): Client
Configures the Tunable request
timeout
of this server or client (if applying the Tunable produces a value ofNone
, an unbounded timeout is used for the request).Configures the Tunable request
timeout
of this server or client (if applying the Tunable produces a value ofNone
, an unbounded timeout is used for the request).If the request has not completed within the Duration resulting from
timeout.apply()
, the pending work will be interrupted via com.twitter.util.Future.raise.Client's Request Timeout
The client request timeout is the maximum amount of time given to a single request (if there are retries, they each get a fresh request timeout). The timeout is applied only after a connection has been acquired. That is: it is applied to the interval between the dispatch of the request and the receipt of the response.
Server's Request Timeout
The server request timeout is the maximum amount of time, a server is allowed to spend handling the incoming request. Using the Finagle terminology, this is an amount of time after which a non-satisfied future returned from the user-defined service times out.
-
def
withResponseClassifier(responseClassifier: ResponseClassifier): Client
Configure a com.twitter.finagle.service.ResponseClassifier which is used to determine the result of a request/response.
Configure a com.twitter.finagle.service.ResponseClassifier which is used to determine the result of a request/response.
This allows developers to give Finagle the additional application-specific knowledge necessary in order to properly classify responses. Without this, Finagle cannot make judgements about application-level failures as it only has a narrow understanding of failures (for example: transport level, timeouts, and nacks).
As an example take an HTTP server that returns a response with a 500 status code. To Finagle this is a successful request/response. However, the application developer may want to treat all 500 status codes as failures and can do so via setting a com.twitter.finagle.service.ResponseClassifier.
ResponseClassifier is a PartialFunction and as such multiple classifiers can be composed together via PartialFunction.orElse.
Response classification is independently configured on the client and server. For client-side response classification using com.twitter.finagle.builder.ClientBuilder, see
com.twitter.finagle.builder.ClientBuilder.responseClassifier
- Definition Classes
- Client → CommonParams
- Note
If unspecified, the default classifier is com.twitter.finagle.service.ResponseClassifier.Default which is a total function fully covering the input domain.
- See also
com.twitter.finagle.http.service.HttpResponseClassifier
for some HTTP classification tools.
-
def
withRetryBackoff(backoff: Stream[Duration]): Client
Configures the requeue backoff policy of this client (default: no delay).
Configures the requeue backoff policy of this client (default: no delay).
The
backoff
policy is represented by a stream of delays (i.e.,Stream[Duration]
) used to delay each retry.- Definition Classes
- Client → ClientParams
- See also
https://twitter.github.io/finagle/guide/Clients.html#retries
-
def
withRetryBudget(budget: RetryBudget): Client
Configures the retry budget of this client (default: allows for about 20% of the total requests to be retried on top of 10 retries per second).
Configures the retry budget of this client (default: allows for about 20% of the total requests to be retried on top of 10 retries per second).
This
budget
is shared across requests and governs the number of retries that can be made by this client.- Definition Classes
- Client → ClientParams
- Note
The retry budget helps prevent clients from overwhelming the downstream service.
- See also
https://twitter.github.io/finagle/guide/Clients.html#retries
-
val
withSession: ClientSessionParams[Client]
An entry point for configuring the client's session.
An entry point for configuring the client's session.
- Definition Classes
- Client → WithClientSession
-
val
withSessionQualifier: SessionQualificationParams[Client]
An entry point for configuring the client's session qualifiers (e.g.
An entry point for configuring the client's session qualifiers (e.g. circuit breakers).
- Definition Classes
- Client → WithSessionQualifier
- See also
https://twitter.github.io/finagle/guide/Clients.html#circuit-breaking
-
def
withStack(fn: (Stack[ServiceFactory[Command, Response]]) ⇒ Stack[ServiceFactory[Command, Response]]): Client
A new StackClient using the function to create a new Stack.
A new StackClient using the function to create a new Stack.
The input to
fn
is the client's current stack. This API allows for easier usage when writing code that uses method chaining.This method is similar to transformed while providing easier API ergonomics for one-off
Stack
changes.- Definition Classes
- Client → EndpointerStackClient → StackClient
From Scala:
import com.twitter.finagle.Http Http.client.withStack(_.prepend(MyStackModule))
From Java:
import com.twitter.finagle.Http; import static com.twitter.util.Function.func; Http.client().withStack(func(stack -> stack.prepend(MyStackModule)));
- See also
withStack(Stack)
Example: -
def
withStack(stack: Stack[ServiceFactory[Command, Response]]): Client
A new StackClient with the provided
stack
.A new StackClient with the provided
stack
.- Definition Classes
- Client → EndpointerStackClient → StackClient
- See also
withStack
that takes aFunction1
for a more ergonomic API when used with method chaining.
-
def
withStatsReceiver(statsReceiver: StatsReceiver): Client
Configures this server or client with given stats.StatsReceiver (default: stats.DefaultStatsReceiver).
Configures this server or client with given stats.StatsReceiver (default: stats.DefaultStatsReceiver).
- Definition Classes
- Client → CommonParams
-
def
withTracer(tracer: Tracer): Client
Configures this server or client with given tracing.Tracer (default: com.twitter.finagle.tracing.DefaultTracer).
Configures this server or client with given tracing.Tracer (default: com.twitter.finagle.tracing.DefaultTracer).
- Definition Classes
- Client → CommonParams
-
val
withTransport: ClientTransportParams[Client]
An entry point for configuring the client's com.twitter.finagle.transport.Transport.
An entry point for configuring the client's com.twitter.finagle.transport.Transport.
Transport
is a Finagle abstraction over the network connection (i.e., a TCP connection).- Definition Classes
- Client → WithClientTransport
Deprecated Value Members
-
def
transformed(f: (Stack[ServiceFactory[Command, Response]]) ⇒ Stack[ServiceFactory[Command, Response]]): Client
Creates a new StackClient with
f
applied tostack
.Creates a new StackClient with
f
applied tostack
.This is the same as withStack.
- Definition Classes
- EndpointerStackClient
- Annotations
- @deprecated
- Deprecated
(Since version 2018-10-30) Use withStack(Stack[ServiceFactory[Req, Rep]] => Stack[ServiceFactory[Req, Rep]]) instead