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.18, 0.19 (>=0.18.0,<0.20)

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.1

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

Built distribution (wheel)

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

Total release size: 21.9 kB

Release files / foca_plugin_generic_routing_random-0.1.1.tar.gz

Download URL foca_plugin_generic_routing_random-0.1.1.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
13755fdf9d69aaf861820d8aa11f52fcaa7ae1b38c5d7f3f62cc104758077aad
BLAKE2b-256 checksum
How to use checksums
50e58bae0b52c81bc683d7283ef853b602da77c7f10bf95e7937c9d9c29255eb
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 1, 2026.

Transparency log

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

Download URL foca_plugin_generic_routing_random-0.1.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fdb27ead4789efb54eab95ee1c6aa8fd0f45999204593628ada4a32a35e6bf95
BLAKE2b-256 checksum
How to use checksums
92a8a6169a34243208ad3bfae405152d8a8e3f2ca1d395503faaf8b5691a20ad
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 1, 2026.

Transparency log

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

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.1.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 1, 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