Skip to main content

Crate hook0_client

Crate hook0_client 

Source
Expand description

This is the Rust client for Hook0. It makes it easier to send events from a Rust application to a Hook0 instance.

§Sending an event is idempotent, and retried

Hook0Client::send_event sends every event under an ID it knows: the one set on the Event, or a UUIDv7 it generates when the event carries none. Passing no ID no longer means the ID comes from Hook0 — the interface is unchanged, but the value now comes from the client, is sent with the request and is what send_event returns.

That is what makes retrying safe. Hook0 keys events on their ID, so a request that is repeated after a network failure or a server error ingests the event once rather than twice; without a client-chosen ID, a repeated request would create a second event and deliver it to every subscriber.

Every send is bounded, and every bound is configurable: Hook0Client::with_max_payload_bytes rules an oversized payload out before anything is sent, Hook0Client::with_request_timeout bounds one attempt, Hook0Client::with_max_response_bytes bounds what an answer may cost to read, and RetryPolicy bounds how many attempts are made and how long they may spend waiting between them. Pass RetryPolicy::disabled to send each event exactly once.

Modules§

generated
Everything the API document describes, written by the SDK generator and never by hand.

Structs§

Event
An event that can be sent to Hook0
Hook0Client
The Hook0 client
RetryPolicy
How a client spaces out the attempts of a single send.

Enums§

Hook0ClientError
Every error Hook0 client can encounter

Constants§

DEFAULT_MAX_PAYLOAD_BYTES
Largest event payload the client agrees to send, unless it is told otherwise with Hook0Client::with_max_payload_bytes.
DEFAULT_MAX_RESPONSE_BYTES
Largest answer the client reads off the socket, unless it is told otherwise with Hook0Client::with_max_response_bytes.
DEFAULT_REQUEST_TIMEOUT
Longest one attempt at reaching Hook0 is given before it is abandoned, unless the client is told otherwise with Hook0Client::with_request_timeout.
MAX_ATTEMPTS_CAP
Most attempts a RetryPolicy can ever make, whatever max_attempts says.
MAX_HEADER_BYTES
Longest one header line may be, its name and its value together, in bytes.
MAX_HEAD_BYTES
Largest whole head an answer may carry, every line counted together, in bytes.
MAX_RESPONSE_HEADERS
Header lines an answer may carry before this client refuses to read it.

Functions§

verify_webhook_signature
Verifies the signature of a webhook
verify_webhook_signature_with_current_time
Verifies the signature of a webhook