fairness

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README

Fairness Policies

Fairness policies determine which active flow within a Priority Band is selected for the next dispatch opportunity. They manage contention between tenants or models sharing the same priority level.

This corresponds to Tier 2 of the strict 3-Tier Dispatch Hierarchy in the Flow Control system:

  1. Priority (Band Selection): Selects the highest-priority Band that has pending work.
  2. Fairness (Flow Selection): [Implemented by this package] Determines which Flow within that band gets the next dispatch opportunity.
  3. Ordering (Item Selection): Determines which Request from that specific flow's queue is dispatched.

Architecture: The Flyweight Pattern

Fairness policies must often maintain state (e.g., Round Robin cursors) for each Priority Band they govern. To support this efficiently without creating a new plugin instance for every Band, this package uses the Flyweight pattern:

  1. The Plugin Instance is a Singleton containing only immutable configuration.
  2. The State is created via NewState() and stored on the Band.
  3. The Logic (Pick method) accepts the State as an argument during execution.

Available Implementations

  • Round Robin (round-robin-fairness-policy): Cycles through active flows one by one to guarantee no single flow can starve others.
  • Global Strict (global-strict-fairness-policy): A greedy strategy that ignores flow boundaries and picks the absolute "best" request globally.

Conformance Testing

This directory contains a functional test suite (functional_test.go) that verifies FairnessPolicy implementations against the expected contract.

To run the conformance tests:

go test ./pkg/epp/framework/plugins/flowcontrol/fairness/...

To include a new fairness policy in these tests, add its factory to the local policies map inside TestFairnessPolicyConformance within functional_test.go.

Documentation

Overview

Package fairness provides the standard implementations of the FairnessPolicy interface.

For a detailed description of the concepts and available implementations, see the README.md file in this directory.

Directories

Path Synopsis
Package globalstrict implements a greedy fairness policy that enforces a strict global ordering across all flows within a priority band, ignoring flow boundaries.
Package globalstrict implements a greedy fairness policy that enforces a strict global ordering across all flows within a priority band, ignoring flow boundaries.
Package programaware implements a flow-control fairness policy that schedules per-program queues using a swappable scoring strategy.
Package programaware implements a flow-control fairness policy that schedules per-program queues using a swappable scoring strategy.
Package roundrobin implements a fairness policy that selects queues from a priority band using a round-robin strategy, cycling through active flows one by one to guarantee that no single flow can starve others.
Package roundrobin implements a fairness policy that selects queues from a priority band using a round-robin strategy, cycling through active flows one by one to guarantee that no single flow can starve others.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL