gosub-sonar
Browser-agnostic priority-scheduled HTTP/HTTPS fetching library.
Overview
gosub-sonar provides two fetching APIs:
simple_get— one-shot GET for tools and scripts that just need bytes.Fetcher— full priority scheduler with request coalescing, per-origin concurrency limits, and fan-out to multiple subscribers.
The library has no dependency on any browser engine and can be used standalone.
Usage
Add to your Cargo.toml (the scheduler API also uses these companion crates directly):
[]
= "0.1"
= "1"
= { = "1", = ["rt", "macros"] }
= "0.7"
= "2"
One-shot GET
use simple_get;
use Url;
let bytes = simple_get.await?;
Priority scheduler
use Arc;
use ;
use Method;
use CancellationToken;
use Url;
// NullContext ignores all lifecycle events; implement FetcherContext to receive them.
let fetcher = new;
let shutdown = new;
let f = fetcher.clone;
let cancel = shutdown.clone;
spawn;
let req = builder
.with_priority
.with_auto_decode
.build;
match fetcher.fetch.await
shutdown.cancel;
For per-subscriber cancellation use fetcher.fetch_with_cancel(req, token); for full control
over the reply channel and request handle use fetcher.submit(req, handle, tx).
See the examples/ directory for runnable versions.
Examples
cargo run --example simple_fetch -- https://example.org
cargo run --example fetcher -- https://example.org
cargo run --example fetcher_harness --features test-support
Documentation
API documentation is available on docs.rs. Design notes live
in the docs/ directory:
- architecture.md — overall structure of the fetch stack
- net-design.md — scheduler design (coalescing, priorities, fan-out)
- pump.md — how streamed bodies are pumped to subscribers
License
MIT — see LICENSE.