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
FOCA 0.18 (>=0.18.0,<0.19)

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.1.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.1.0
File Size Uploaded Provenance Actions
foca_plugin_generic_routing_random-0.1.0.tar.gz 11.9 kB With provenance Details for foca_plugin_generic_routing_random-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 21.6 kB

Release files / foca_plugin_generic_routing_random-0.1.0.tar.gz

Download URL foca_plugin_generic_routing_random-0.1.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cd99db59dfbc4a3b7ec76ec23125b129b9eea882ef702488776b7ee51081f51b
BLAKE2b-256 checksum
How to use checksums
65fb78ecdc2548a2e8fb777e4d545a975f7cd14cd78d5d7624f22cb516a0ae45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 28, 2026.

Transparency log

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

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

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 Oct 28, 2026.

Transparency log

Security for foca-plugin-generic-routing-random 0.1.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.1.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 Oct 28, 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