<commit_before>.. _partitionawareclient:

ThriftMux Partition Aware Client
================================

.. note:: This set of APIs are currently experimental.

This page demonstrates how to enable partition aware routing for ThriftMux/Thrift Client.

Terms
-----

.. glossary::

Partition
  A partition represents a logical entity that processes data.
  It could be a single physical instance or a set of physical instances, each instance
  in a partition can be treated as equivalent over the data that the partition is responsible
  for. Partitions can overlap, instances can belong to different partitions.

Shard / Instance
  A physical instance.

Enable Partition Awareness
--------------------------

Thrift/ThriftMux Client
<<<<<<<<<<<<<<<<<<<<<<<

The set of APIs to configure a client with partitioning is at :finagle-thrift-src:`PartitioningParams
<com/twitter/finagle/finagle-thrift/src/main/scala/com/twitter/finagle/thrift/exp/partitioning/PartitioningParams.scala>`.

- `.strategy(partitioningStrategy: PartitioningStrategy)` configures the client with a
  PartitioningStrategy; it could be either a CustomPartitioningStrategy or a HashingPartitioningStrategy.

- Params only for HashingPartitioningStrategy

  - `.ejectFailedHost(eject: Boolean)` partitions are placed on a
    hash ring, when failure accrual marks partitions as unhealthy,
    this param is for deciding whether to eject the failing
    partitions from the hash ring. By default, this is off.

  - `.keyHasher(hasher:KeyHasher)`, defines the hash function to use
    for partitioned clients when mapping keys to partitions.

  - `.numReps(reps: Int)`, duplicate each node across the hash ring according to reps,
    this will adjust the distribution of partition nodes on the hash ring, higher value
    means more even. The default value is 160.

Use the following code snippet to enable partition awareness for a Finagle client of a hashing
strategy and custom strategy respectively:

.. code-block:: scala
   :linenos:
<commit_msg>finagle/doc: Fix link in PartitionAwareClient documentation<commit_after>.. _partitionawareclient:

ThriftMux Partition Aware Client
================================

.. note:: This set of APIs are currently experimental.

This page demonstrates how to enable partition aware routing for ThriftMux/Thrift Client.

Terms
-----

.. glossary::

Partition
  A partition represents a logical entity that processes data.
  It could be a single physical instance or a set of physical instances, each instance
  in a partition can be treated as equivalent over the data that the partition is responsible
  for. Partitions can overlap, instances can belong to different partitions.

Shard / Instance
  A physical instance.

Enable Partition Awareness
--------------------------

Thrift/ThriftMux Client
<<<<<<<<<<<<<<<<<<<<<<<

The set of APIs to configure a client with partitioning is at :finagle-thrift-src:`PartitioningParams
<com/twitter/finagle/thrift/exp/partitioning/PartitioningParams.scala>`.

- `.strategy(partitioningStrategy: PartitioningStrategy)` configures the client with a
  PartitioningStrategy; it could be either a CustomPartitioningStrategy or a HashingPartitioningStrategy.

- Params only for HashingPartitioningStrategy

  - `.ejectFailedHost(eject: Boolean)` partitions are placed on a
    hash ring, when failure accrual marks partitions as unhealthy,
    this param is for deciding whether to eject the failing
    partitions from the hash ring. By default, this is off.

  - `.keyHasher(hasher:KeyHasher)`, defines the hash function to use
    for partitioned clients when mapping keys to partitions.

  - `.numReps(reps: Int)`, duplicate each node across the hash ring according to reps,
    this will adjust the distribution of partition nodes on the hash ring, higher value
    means more even. The default value is 160.

Use the following code snippet to enable partition awareness for a Finagle client of a hashing
strategy and custom strategy respectively:

.. code-block:: scala
   :linenos:

{'fraction_non_alphanumeric': 0.09059405940594059, 'fraction_numerical': 0.0014851485148514852, 'mean_word_length': 4.187419768934531, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4540419', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1014, 'n_words': 471}