taba-client (Rust)
The Taba Rust connector. Documentation: Connectors, Rust.
Other languages: Português (Brasil) · all languages
- Its own HTTP/1.1 over
std::net::TcpStream(building the request and reading the response are pure functions inhttp), TLS 1.2 or later throughrustlswith the system roots (plus an optional CA of your own) and its own JSON and base64. The only dependencies arerustlsandrustls-native-certs(plusserde, only in the optionalserdefeature). - Thread-safe:
ClientisSend + Sync; a single one serves many. - Call retries of the common contract:
429and503(withRetry-After),502and504only on FIFO, a network failure before sending; never a4xxnor a timeout.
use ;
Consuming with a handler and objects (D140)
The simplest use: publish and consume objects, without serializing or deleting anything by hand. With the serde feature (taba-client = { features = ["serde"] }; without it the connector stays with rustls only):
client.publish_object?;
client.?;
consume_typed reads with long polling, hands over the body already deserialized, deletes the message if the handler returns Ok and renews the invisibility while it runs. The details and customizations follow.
If the body is not a T, consume_typed returns client.invalid-response before the handler and the message is not deleted. Run the tests with the feature: cargo test --workspace --all-features.
Without serde: consume_with
Besides consume, which returns the list, consume_with reads from the queue with long polling (20 s), one message at a time and 120 s of invisibility (this mode's defaults; pass a ConsumeOptions to change them), hands each message to a Delivery and deletes the message if the handler returns Ok (delivery.delete is true by default). While the handler runs, a second thread renews the invisibility every third of it, so no other consumer takes the message. If the handler returns Err, the message is not deleted and the error propagates as ConsumeError::Handler.
Minimal:
loop
Complete, annotated:
let stop = new; // elsewhere (a signal) sets true to end
while !stop.load
Client::call and Call are the lower layer (route, query, body): it is what taba-cli uses to print the responses as the server returned them. taba_client::testing is a fake transport for the tests of whoever uses the connector.
Still missing: the async form (async feature, tokio) and a Transport the application can swap.
License
Apache-2.0. The Taba server is AGPL-3.0-only; the connectors are Apache-2.0 so any application, open or closed, can embed them.