Expand description
The official Rust client for Honk: send events from your apps, jobs, scripts and CI to your phone, as calm, grouped push notifications.
- Async-first on Tokio and
reqwestwith rustls (no OpenSSL); a synchronousblocking::Honkwith the featureblocking. - Every send carries an
Idempotency-Key(yours, or a UUIDv7) that is reused on every retry, so a retry never creates a duplicate. - Retries only network errors, timeouts, 429 and 5xx, with exponential backoff and full
jitter, never sooner than
Retry-After, all under a total deadline (30 s). Redirects are reported, never followed. - Local validation of everything cheap (lengths, URLs, actions, metadata, the 16 KiB body),
with every invalid field reported at once.
HonkBuilder::validate(false)leaves it to the server.
Keep the ingestion key (honk_…) on the server: never ship it inside a client app.
§Quick start
use honk_me::{Honk, Message, Severity};
#[tokio::main]
async fn main() -> honk_me::Result<()> {
let honk = Honk::from_env()?; // HONK_URL, HONK_KEY
// The Honk scale: light, beep, loud, long, blast.
honk.beep("Backup finished", "nightly pg_dump took 42 s").await?;
// Every field, and your own idempotency key.
let msg = Message::new("Ana asked for a quote: 3 rooms, 2 bathrooms")
.title("New quote request")
.severity(Severity::LOUD)
.group_key("requests/4812")
.url("https://shop.example.com/admin/requests/4812")
.metadata("rooms", 3);
let accepted = honk.send(&msg, "request-4812").await?;
println!("stored as {}", accepted.id);
// Incidents: a problem opens one for its group, a recovery closes it.
honk.problem("db/backup", "Backup failed", "pg_dump exited with 1").await?;
honk.recovery("db/backup", "Backup OK", "pg_dump finished").await?;
Ok(())
}§Errors
Every failure is an Error: Validation (fix the message), Auth, Quota, Conflict,
Network, Timeout, Server or Http, each with a Failure holding the details.
Error::is_retryable tells whether sending again later (with the same idempotency key)
may succeed.
§Features
blocking:blocking::Honk, a synchronous client on a private Tokio runtime.
Modules§
- blocking
blocking - A synchronous client (feature
blocking), for scripts, CLIs and code without an async runtime. It wraps the asyncHonkon a private single-threaded Tokio runtime, so it has the same retries, deadline, idempotency and validation.
Structs§
- Accepted
- The
202answer: the message is durably stored. It does not mean pushed, delivered or read. - Action
- A button on a message. Honk never opens the URL; the phone does, when you tap the button.
- Defaults
- Values applied to every message that leaves these fields unset.
- Failure
- The details of a failed send.
- Field
Error - One invalid field, from the server (
error.fields[]) or local validation. - Honk
- Sends messages to one Honk project. Cheap to clone (the connection pool is shared); create
one per application and reuse it so connections are kept alive. Needs a Tokio runtime; see
blocking::Honk(featureblocking) for synchronous code. - Honk
Builder - Configures a
Honkclient. URL and key are required; everything else has a default. - Message
- One event for
POST /v1/messages. Only the message text is required; unset fields are omitted so the server defaults apply (severity info, priority normal, sourceapi, environmentdefault, channelgeneral, event type event, TTL 3600 s). Empty strings count as unset. - Parse
Enum Error - The error of
Severity::from_strand the other enums’from_str: names the valid values. - Pending
Send - A send prepared by a helper (
Honk::loud,Honk::problem, …). Chain more fields, then.awaitit (or callsend).
Enums§
- Category
- The category (taxonomy v1).
- Error
- Everything that can go wrong. Every variant except
InvalidConfigurationcarries aFailurewith the details (status, API error code, field errors, the idempotency key that was used, attempts, …). - Event
Type - A problem opens an incident for its group, a recovery closes it. Both need a group key.
- Metadata
Value - A metadata value: a string, a number or a boolean.
- Priority
- The priority declared by the source.
Urgentneeds an ingestion key withallow_urgent(otherwise403 priority_not_allowed). - Severity
- Severity, lowest to highest.
ErrorandCriticalraise the effective priority to at leastHigh. Every severity has a horn name on the Honk scale:Severity::LIGHT,Severity::BEEP,Severity::LOUD,Severity::LONG,Severity::BLAST.
Constants§
- MAX_
ACTIONS - The most actions (buttons) on a message.
- MAX_
ACTION_ TITLE - The longest action title, in characters.
- MAX_
BODY_ BYTES - The largest JSON body Honk accepts: 16 KiB.
- MAX_
CHANNEL - The longest channel, in characters.
- MAX_
ENVIRONMENT - The longest environment, in characters.
- MAX_
GROUP_ KEY - The longest group key, in characters.
- MAX_
MESSAGE_ BYTES - The longest message text, in bytes of UTF-8.
- MAX_
METADATA_ KEYS - The most metadata keys.
- MAX_
METADATA_ STRING - The longest metadata string value, in characters.
- MAX_
SOURCE - The longest source, in characters.
- MAX_
TITLE - The longest title, in characters.
- MAX_
TTL_ SECONDS - The longest push lifetime, in seconds.
- MAX_
URL_ BYTES - The longest
url,image_urlor action URL, in bytes. - MIN_
TTL_ SECONDS - The shortest push lifetime, in seconds.
- VERSION
- The version of this crate, sent in the
User-Agentheader (honk-me-rust/<version>).
Functions§
- encode_
message - Validates
message(unlessvalidateis false) withdefaultsapplied and returns the exact JSON body thatHonk::sendposts. Useful for logging, dry runs and tests. - new_
idempotency_ key - A new UUIDv7 (RFC 9562: 48-bit Unix milliseconds, then random bits), the default
Idempotency-Key. Store it with your job if you want to retry the same event across process restarts.
Type Aliases§
- Result
- A
Resultwhose error ishonk_me::Error.