Skip to content

group ​

Outbound groups: a human's choice, kept between runs, or a choice by probes; of one member or of several, among which connections are shared.

Crateours-mod-group, modules/routing/group
Binary featuregroup; group-probe → ours-mod-group/probe
Crate featuresprobe (ours-http, http)

requires ​

  • tls — the probes' HTTP client takes TLS from the ours_tls_options::Tls factory (Tls::of(cx.services)).
  • cache — the choice in a group is saved in the cache file (ours_api::cache::of); the crate does not depend on ours-mod-cache.

provides ​

  • Provide::Outbound { key: "group" } — a group is an outbound. It is written in the groups section, and the loader turns it into an outbound of kind group; set_persistent_tag(true) — a group of the native configuration always has a name, and the choice is stored by it.
  • Provide::Schema { name: "groups" } — members name outbounds or are matched against them.

Syntax: groups.

Dependencies ​

ours-http (probes), ours-tls-options, ours-atomic64, ours-bufpool, ours-api, ours-codec, ours-json, http.

Design ​

  • src/options.rs — GroupOptions; Rank: Manual (a human's choice), Order (the first to answer, in order), Delay (the fastest by the last probe), Stable (fast and steady over samples, allowing max_failures); Pick (Count(n)/All), Spread, Probe (url, interval, idle_timeout, tolerance, recovery).
  • src/lib.rs — Group (an outbound): members are resolved through the current DialTable; Inner::target chooses a member; Pinned — a member pinned to a connection regardless of later changes; Unavailable — a group without members (subscriptions are empty) refuses new connections until a reload. inherit_selection carries the choice over on reload.
  • src/probe.rs — Prober: one scheduler and I/O runtime per process; it survives the groups' reload, so that warmed-up mux sessions keep being served. Probes are bounded by a semaphore, a 15 s timeout; probe_once joins a check already in progress.
  • src/probe_disabled.rs — a build without probe: manual groups only.
  • src/spread.rs — Spreader: Hash (a site = the last two labels of the domain, or the address), round-robin, random (SplitMix64 without locks), Sticky (a client on a site keeps a member for a given time); it remembers up to 1000 bindings.
  • src/interrupt.rs — Epoch/Signal: interrupting existing connections when the choice changes (interrupt_exist_connections). Without it a group's streams are transparent and stay usable for splice.

Specifics ​

A group starts only after commit; a manual choice is kept across a failed reload and a restart.

Tests ​

modules/routing/group/tests/groups.rs (real forwarding, interruption, URL probes, the saved choice), tests/lifecycle.rs (starting after commit, the choice across failed reloads/restarts).

GPL-3.0-or-later