TClientPool

Manages a pool of TClients for the given interface, forwarding RPC calls to members of the pool.

If a request fails, another client from the pool is tried, and optionally, a client is disabled for a configurable amount of time if it fails too often. If all clients fail (and keepTrying is false), a TCompoundOperationException is thrown, containing all the collected RPC exceptions.

Constructors

this
this(Client[] clients)

Creates a new instance and adds the given clients to the pool.

Members

Aliases

Client
alias Client = TClientBase!Interface

Shorthand for TClientBase!Interface, the client type this instance operates on.

Functions

addClient
void addClient(Client client)

Adds a client to the pool.

execute
ResultType execute(ResultType delegate(Client) work)

Executes an operation on the first currently active client.

executeOnPool
ResultType executeOnPool(ResultType delegate(Client) work)
Undocumented in source. Be warned that the author may not have intended to support it.
faultDisableCount
ushort faultDisableCount()
void faultDisableCount(ushort value)

The number of consecutive faults after which a client is disabled until faultDisableDuration has passed. 0 to never disable clients.

faultDisableDuration
Duration faultDisableDuration()
void faultDisableDuration(Duration value)

The duration for which a client is no longer considered after it has failed too often.

keepTrying
bool keepTrying()
void keepTrying(bool value)

Whether to keep trying to find a working client if all have failed in a row.

permuteClients
bool permuteClients()
void permuteClients(bool value)

Whether to use a random permutation of the client pool on every call to execute(). This can be used e.g. as a simple form of load balancing.

removeClient
bool removeClient(Client client)

Removes a client from the pool.

Variables

reopenTransports
bool reopenTransports;

Whether to open the underlying transports of a client before trying to execute a method if they are not open. This is usually desirable because it allows e.g. to automatically reconnect to a remote server if the network connection is dropped.

rpcFaultFilter
bool delegate(Exception) rpcFaultFilter;

Called to determine whether an exception comes from a client from the pool not working properly, or if it an exception thrown at the application level.

Meta