Skip to main content

generic.routing.random

Routes requests to the candidate backends in random order, so that they spread over all backends without round-robin state. The successor of proTES's random task distribution.

Plugin ID generic.routing.random
Distribution foca-plugin-generic-routing-random
Import path foca_plugins.generic.routing.random
APIs all (*)
Phases route
Maturity experimental
Data transfers none
Data stored none (no plugin store)
FOCA 0.19, 0.20, 0.21, 0.22, 0.23 (>=0.19.0,<0.24)

What it does

  • route: returns all candidate backends, shuffled with the operating system's randomness (random.SystemRandom). It drops no candidate and adds none; the gateway then tries them in that order. It records the annotations candidates (their number) and seeded (whether a seed was used).

It never rejects a request and never raises NotApplicable. The order itself is in the provenance of each request (route.candidates_out), so the plugin doesn't record it again.

FOCA's default router, foca.routing.ordered, keeps the order of the backend list and shuffles only the backends of each service registry among themselves. This plugin shuffles all candidates, configured or discovered.

Configuration

Admin settings, in the gateway app's configuration (FOCA's plugins section):

plugins:
  available:
    generic.routing.random:
      distribution: foca-plugin-generic-routing-random
      config:
        allow_seed: false  # default; true only for tests
  pipeline:
    - id: route
      alternatives:
        - plugin: generic.routing.random
Setting Type Default Description
config.allow_seed boolean false whether pipelines may set seed
params.seed integer or null null seed of the shuffling, for reproducible orders in tests; refused (when pipelines are resolved) unless allow_seed is set

With a seed, the order is a function of the seed and the candidate list, on the same Python version (Python doesn't promise the same shuffles across versions). Seeded orders are predictable, also for clients that choose the plugin in their own pipelines: keep allow_seed off in production. A test setup:

plugins:
  available:
    generic.routing.random:
      config:
        allow_seed: true  # tests only
  pipeline:
    - id: route
      alternatives:
        - plugin: generic.routing.random
          params:
            seed: 42

proTES's old default

proTES used to try distance-based routing first and fall back to random routing. The same pipeline with plugins, once distance routing (tes.routing.distance) is released:

plugins:
  pipeline:
    - id: route
      alternatives:
        - plugin: tes.routing.distance
        - plugin: generic.routing.random

Installation

pip install foca-plugin-generic-routing-random

See "Installing" in the docs for release trains and derived images.

Development

From the repository root, with the development environment set up (see "Contributing" in the docs):

uv run ruff check plugins/generic/routing/random
uv run python -m scripts.packages mypy plugins/generic/routing/random
uv run coverage run --source plugins/generic/routing/random/src \
  -m pytest plugins/generic/routing/random
uv run coverage report

Changelog

See CHANGELOG.md.

Metadata

Release files for foca-plugin-generic-routing-random 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foca-plugin-generic-routing-random 0.2.0
File Size Uploaded Provenance Actions
foca_plugin_generic_routing_random-0.2.0.tar.gz 12.1 kB With provenance Details for foca_plugin_generic_routing_random-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for foca-plugin-generic-routing-random 0.2.0
File Interpreter ABI Platform Actions
foca_plugin_generic_routing_random-0.2.0-py3-none-any.whl Python 3 none any Details for foca_plugin_generic_routing_random-0.2.0-py3-none-any.whl

Total release size: 21.8 kB

Release files / foca_plugin_generic_routing_random-0.2.0.tar.gz

Download URL foca_plugin_generic_routing_random-0.2.0.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ca23f3aade3a96ecc2a8028751f3e15f6ef9f9936562fa5d4e8b2311e45fdee7
BLAKE2b-256 checksum
How to use checksums
1dd1fb1797b670541fe35b3fe49961543d16e9e306b783a19e3938907f15d4e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / foca_plugin_generic_routing_random-0.2.0-py3-none-any.whl

Download URL foca_plugin_generic_routing_random-0.2.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
402e17069f42aefafc7038ac5ef51ac6dfb5610ed14a8987e5cc26f7abedd8ee
BLAKE2b-256 checksum
How to use checksums
fc86596da040eb664efb965c48619e3f601f884458599d9b7e1641f0496750f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for foca-plugin-generic-routing-random 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for foca_plugin_generic_routing_random-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page