| Crates.io | detsys-srv |
| lib.rs | detsys-srv |
| version | 0.4.0 |
| created_at | 2025-02-05 17:13:29.822496+00 |
| updated_at | 2025-03-19 15:51:21.158628+00 |
| description | Rust client for communicating with SRV-located services |
| homepage | https://github.com/DeterminateSystems/detsys-srv |
| repository | https://github.com/DeterminateSystems/detsys-srv |
| max_upload_size | |
| id | 1544442 |
| size | 93,195 |
Rust client for communicating with services located by DNS SRV records.
SRV Records, as defined in RFC 2782, are DNS records of the form
_Service._Proto.Name TTL Class SRV Priority Weight Port Target
For instance, a DNS server might respond with the following SRV records for
_http._tcp.example.com:
_http._tcp.example.com. 60 IN SRV 1 100 443 test1.example.com.
_http._tcp.example.com. 60 IN SRV 2 50 443 test2.example.com.
_http._tcp.example.com. 60 IN SRV 2 50 443 test3.example.com.
A client wanting to communicate with this example service would first try to
communicate with test1.example.com:443 (the record with the lowest
priority), then with the other two (in a random order, since they are of the
same priority) should the first be unavailable.
detsys-srv handles the lookup and caching of SRV records as well as the ordered
selection of targets to use for communication with SRV-located services.
[SrvClient::new] creates a client (that should be reused to take advantage of
caching) for communicating with the service located by _http._tcp.example.com.
[SrvClient::execute] takes in a future-producing closure (emulating async
closures, which are currently unstable) and executes the closure on a series of
targets parsed from the discovered SRV records, stopping and returning the
first Ok or last Err it obtains.
detsys-srv provides multiple resolver backends for SRV lookup and by default uses
a target selection policy that maintains affinity for the last target it has
used successfully. Both of these behaviors can be changed by implementing the
SrvResolver and Policy traits, respectively.
cargo testcargo fmtcargo clippy --tests -- -Dclippy::allsrc/lib.rs) or README.tpl, update README.md:
cargo install cargo-readmecargo readme > README.mdForked from https://github.com/deshaw/srv-rs/.