Expand description
The Rust SDK for the HTTP server API of Centrifugo: every API method, including those of Centrifugo PRO; tokens; proxy handlers and the endpoints client SDKs call.
use cent::{Client, Config, PublishRequest};
let client = Client::new(Config::new("http://localhost:8000/api").api_key("secret"))?;
let data = cent::json(&serde_json::json!({"text": "hello"}))?;
let res = client.publish(PublishRequest::new("news").data(data)).await?;
println!("published at offset {}", res.offset);§The client
Client - and blocking::Client, with the blocking feature - has a
method per API method, taking its request and returning its result, both
generated from Centrifugo’s api.proto. A request’s new takes the fields
Centrifugo requires; a method per field sets the others:
PublishRequest::new("news").data(data).idempotency_key("k").
- Payloads are JSON, as
RawValue: kept exactly - number text included - in requests and results alike, so a payload from a reply goes back out as the same JSON value. JSONnullisSomeof a null; unset isNone.serde_jsonwrites NaN and infinities asnull: check floats before encoding them. Write integers which may pass 2^53 as JSON strings: browsers decode JSON numbers as doubles.jsonencodes any serde type as a payload, andPayloadExt::decodedecodes one:.data(cent::json(&message)?),publication.data.decode::<Message>()?. - One deadline per call:
Config::request_timeout, or the call’s ownClient::with_timeout, which replaces it; aClient::with_deadlineonly shortens it, never extends it. Every timeout isError::Timeout. - Every call returns an error unless it did everything asked. A
broadcast or batch in which some parts failed returns
Error::BroadcastFailedChannelsorError::BatchFailedCommands, holding every part’s outcome - seeClient::broadcastandBatch. - Retries:
retryablesays whether a new attempt may succeed; retry a publication only with the sameidempotency_key, so that it is not published twice.Client::broadcast_with_retryretries only the channels which may still succeed. Centrifugo remembers a key per channel for five minutes by default, and a second publication under the same key is not published: a key derived from an entity must name the event too,order-42-paidrather thanorder-42. The memory, Redis and PostgreSQL brokers keep keys; the NATS broker ignores them. - Automatic batching:
AutoBatchsends concurrent calls together once enough requests are in flight, never waiting for a timer. - Shutdown:
Client::closerefuses new calls and waits for those in progress. - Tests of code using the client need no Centrifugo: give it an
HttpClientanswering as Centrifugo does - see the README.
§Tokens, proxy handlers, endpoints
token signs connection, subscription and Centrifugo PRO server API
tokens, and builds JWKS. proxy answers Centrifugo’s HTTP proxy;
endpoints serves what the getToken and getSignature callbacks of
client SDKs call, and JWKS; sharedpoll signs shared poll
subscriptions. Each endpoint is a Handler - one function from an
http::Request<Bytes> to a response, served from any framework, and a
tower::Service with the tower feature. Command writes API calls
for Centrifugo’s async consumers.
§Features
| Feature | Default | What |
|---|---|---|
client | yes | The async Client, on tokio, with hyper and rustls |
token | yes | token, sharedpoll, and the JWKS endpoint |
blocking | blocking::Client | |
tower | Handler as a tower::Service |
cent implements the Centrifugo server SDK specification, version 0.4.
Re-exports§
pub use token::Expiry;token
Modules§
- blocking
blocking - A blocking client, for code without an async runtime.
- endpoints
- The endpoints client SDKs call: what their
getTokencallbacks fetch for connection and subscription tokens, what a shared poll subscription’sgetSignaturecallback fetches, and the JWKS endpoint Centrifugo fetches public keys from. - proxy
- The backend side of Centrifugo’s HTTP
proxy, which calls the
application when a client connects, subscribes, publishes or makes an RPC
call: a
Handlerper proxy type, built from a function taking the decoded request and returning a result or aRejection. - sharedpoll
token - Signatures for shared poll subscriptions, which clients tracking keys of a shared poll channel need from the backend. Shared poll subscriptions are experimental in Centrifugo, and the module follows their changes.
- token
token - Tokens: the connection and subscription tokens Centrifugo authenticates clients with, the server API tokens of Centrifugo PRO, and JWKS.
Structs§
- ApiError
- An error Centrifugo returned: it understood the request, and refused it or failed to carry it out. It is the same whether Centrifugo puts it in a 200 reply or, in its transport error mode, in the body of an HTTP error status.
- Apns
Push Notification - ApnsPushNotification is a notification for APNs. Centrifugo PRO only.
- Auto
Batch client - Lets the client send concurrent calls together, as one batch request, once enough of them are in flight. Off unless set.
- Backoff
client - The wait before retrying, growing exponentially with the attempt: see
exponential_backoff. - Batch
client - Commands sent to Centrifugo in one request. Create one with
Client::new_batch, add commands with its methods - one per API method, such asBatch::publish- thensendit: - Batch
Failed Commands Error client - A batch in which one or more commands failed, up to all of them. Every
command got its own reply: each one’s outcome, success or failure, is in
its
Pending. - Batch
Options client - How Centrifugo runs a batch. The options are set when the batch is created, since they change what its commands mean together: in what order they take effect.
- Batch
Result client - The outcome of a sent batch as a whole: each command’s own result is in
the
Pendingits method returned. Encoded as JSON, it gives the failed commands with their errors. - Block
User Request - BlockUserRequest blocks a user: the user is disconnected and can not connect again until unblocked or the block expires. Centrifugo PRO only.
- Block
User Result - BlockUserResult is the result of a block user call. Empty at the moment. Centrifugo PRO only.
- Broadcast
Attempt client - A failed attempt of
Client::broadcast_with_retry, for itson_attempt_errorcallback. - Broadcast
Failed Channels Error - A broadcast which Centrifugo carried out, and which failed in one or more of its channels, up to all of them: the others got the publication.
- Broadcast
Request - BroadcastRequest publishes the same data into many channels.
- Broadcast
Result - The outcome of a broadcast: one entry per channel, in the order the request listed them.
- Broadcast
Retry Options client - How
Client::broadcast_with_retryretries. The default retries once, after a wait of about 100 milliseconds. - Cancel
Push Request - CancelPushRequest cancels a delayed push notification (sent with send_at). Centrifugo PRO only.
- Cancel
Push Result - CancelPushResult is the result of a cancel push call. Empty at the moment. Centrifugo PRO only.
- Channel
Context - ChannelContext is context of a channel subscription. Centrifugo PRO only.
- Channel
Info - ChannelInfo is information about an active channel.
- Channel
Result - The outcome of a broadcast in one channel.
- Channels
Request - ChannelsRequest returns active channels (with one or more subscribers). It can be heavy on large deployments: there is no pagination.
- Channels
Result - ChannelsResult is the result of a channels call.
- Client
client - Calls Centrifugo’s HTTP server API: a method per API method, taking its request and returning its result.
- Client
Info - ClientInfo describes a client connection.
- Command
- An API call left for Centrifugo’s async
consumers to make, instead
of calling Centrifugo: written to a PostgreSQL outbox table, a Kafka topic,
a Redis stream. A function per API method makes one, such as
Command::publish: it checks the request as the client does before sending it - an invalid request fails here, rather than in a consumer, which drops a command it cannot run - and encodes it. - Config
client - Configures a
Client.Client::newchecks it, and reports every mistake it can see before any request is made. - Connection
Info - ConnectionInfo is information about a client connection. Centrifugo PRO only.
- Connection
State - ConnectionState is the state of a client connection. Centrifugo PRO only.
- Connection
Token Info - ConnectionTokenInfo is information about a connection token. Centrifugo PRO only.
- Connections
Request - ConnectionsRequest returns information about active connections, without the need to enable presence. At least one of user, expression or label_filter must be set. Centrifugo PRO only.
- Connections
Result - ConnectionsResult is the result of a connections call. Centrifugo PRO only.
- Decode
Error - A reply which is not Centrifugo’s: usually an
api_endpointwhich does not point at Centrifugo’s API, so that something else answers instead. - Default
Http Client client - The HTTP client a
Clientuses unless given another: hyper with rustls, verifying certificates with the operating system’s trust store. - Delete
User Status Request - DeleteUserStatusRequest deletes the status of users. Centrifugo PRO only.
- Delete
User Status Result - DeleteUserStatusResult is the result of a delete user status call. Empty at the moment. Centrifugo PRO only.
- Device
- Device is a device registered for push notifications. Centrifugo PRO only.
- Device
Filter - DeviceFilter selects devices. Centrifugo PRO only.
- Device
List Request - DeviceListRequest returns a paginated list of registered devices. Centrifugo PRO only.
- Device
List Result - DeviceListResult is the result of a device list call. Centrifugo PRO only.
- Device
Locale Update - DeviceLocaleUpdate sets the locale of devices. Centrifugo PRO only.
- Device
Meta Update - DeviceMetaUpdate sets the meta of devices. Centrifugo PRO only.
- Device
Register Request - DeviceRegisterRequest registers a device for push notifications, or updates a registered one. Centrifugo PRO only.
- Device
Register Result - DeviceRegisterResult is the result of a device register call. Centrifugo PRO only.
- Device
Remove Request - DeviceRemoveRequest removes devices, selected by ids and/or users. Centrifugo PRO only.
- Device
Remove Result - DeviceRemoveResult is the result of a device remove call. Empty at the moment. Centrifugo PRO only.
- Device
Timezone Update - DeviceTimezoneUpdate sets the timezone of devices. Centrifugo PRO only.
- Device
Topic - DeviceTopic is a topic subscription of a device. Centrifugo PRO only.
- Device
Topic Filter - DeviceTopicFilter selects device topic subscriptions. Centrifugo PRO only.
- Device
Topic List Request - DeviceTopicListRequest returns a paginated list of device topic subscriptions. Centrifugo PRO only.
- Device
Topic List Result - DeviceTopicListResult is the result of a device topic list call. Centrifugo PRO only.
- Device
Topic Update Request - DeviceTopicUpdateRequest changes the topics of a device. The device topic list is what decides who gets a push sent to a topic. Centrifugo PRO only.
- Device
Topic Update Result - DeviceTopicUpdateResult is the result of a device topic update call. Empty at the moment. Centrifugo PRO only.
- Device
Topics Update - DeviceTopicsUpdate changes the topics of devices. Centrifugo PRO only.
- Device
Update Request - DeviceUpdateRequest updates registered devices, selected by ids and/or users. Centrifugo PRO only.
- Device
Update Result - DeviceUpdateResult is the result of a device update call. Empty at the moment. Centrifugo PRO only.
- Device
User Update - DeviceUserUpdate sets the user of devices. Centrifugo PRO only.
- Disconnect
- Disconnect describes the code and reason clients are disconnected with.
- Disconnect
Request - DisconnectRequest disconnects a user’s connections.
- Disconnect
Result - DisconnectResult is the result of a disconnect call. Empty at the moment.
- Failed
Command client - The failure of one command of a batch.
- FcmPush
Notification - FcmPushNotification is a notification for FCM. Centrifugo PRO only.
- Filter
Node - FilterNode is a tree describing a predicate over client labels. Used as label_filter on Subscribe, Unsubscribe, Disconnect, Refresh and Connections requests. A node is either a leaf comparison (key, cmp, val or vals) or a logical operation (op) over child nodes. Centrifugo PRO only: defined here for protocol-surface consistency, Centrifugo OSS parses it but ignores it.
- Function
Error - An error of the application’s function given to
Config::with_endpoint_fnorConfig::bearer_token: the function’s own error, its source, and the function’s name. - GetUser
Status Request - GetUserStatusRequest returns the status of users. Centrifugo PRO only.
- GetUser
Status Result - GetUserStatusResult is the result of a get user status call. Centrifugo PRO only.
- Handler
- An HTTP endpoint: a proxy handler, an endpoint client SDKs call, or a JWKS
endpoint. It is one function,
handle, from a request with its whole body to a response, holding all of the endpoint’s behaviour - statuses, headers, body limits - so that it serves from any framework: - History
Item - A publication read by
history_all, with the epoch of the stream it was read from: itspositionis where to resume reading, or therecover_sinceof a subscription, with no fields copied by hand (spec 3.8). It derefs to thePublication:item.offset,item.data. - History
Remove Request - HistoryRemoveRequest removes publications from the history of a channel. The current top stream position is kept, so clients do not get disconnected because of insufficient state.
- History
Remove Result - HistoryRemoveResult is the result of a history remove call. Empty at the moment.
- History
Request - HistoryRequest returns publications from the history of a channel. History must be enabled for the channel.
- History
Result - HistoryResult is the result of a history call.
- HmsPush
Notification - HmsPushNotification is a notification for HMS. Centrifugo PRO only.
- Http
Error - A reply with an HTTP status other than 200 OK: the request did not reach the API method at all.
- Info
Request - InfoRequest returns information about the running Centrifugo nodes.
- Info
Result - InfoResult is the result of an info call.
- Invalid
Config Error - A client not created - or used where it cannot work - with a message naming the option and the fix.
- Invalid
Request Error - A request the client did not send, because it could tell it is wrong: a publication without a channel or data, say. Only rules which hold for every Centrifugo are checked; everything else is Centrifugo’s to check.
- Invalidate
User Tokens Request - InvalidateUserTokensRequest revokes all tokens of a user issued before a certain time (based on the iat claim of a JWT). Centrifugo PRO only.
- Invalidate
User Tokens Result - InvalidateUserTokensResult is the result of an invalidate user tokens call. Empty at the moment. Centrifugo PRO only.
- MapClear
Request - MapClearRequest removes all state and stream data of a map channel.
- MapClear
Result - MapClearResult is the result of a map clear call. Empty at the moment.
- MapEntry
- MapEntry is an entry of a map channel state or stream.
- MapPublish
Request - MapPublishRequest publishes or updates a key in a map channel.
- MapPublish
Result - MapPublishResult is the result of a map publish call.
- MapRead
State Request - MapReadStateRequest reads the current state of a map channel, with optional pagination.
- MapRead
State Result - MapReadStateResult is the result of a map read state call.
- MapRead
Stream Request - MapReadStreamRequest reads the change stream of a map channel.
- MapRead
Stream Result - MapReadStreamResult is the result of a map read stream call.
- MapRemove
Request - MapRemoveRequest removes a key from a map channel.
- MapRemove
Result - MapRemoveResult is the result of a map remove call.
- MapState
Item - An entry read by
map_read_state_all, with the position of the state it was read at: reading the map’s stream fromstatewithmap_read_streamgets every change made since (spec 3.8). It derefs to theMapEntry:item.key,item.data. - MapStats
Request - MapStatsRequest returns statistics about a map channel.
- MapStats
Result - MapStatsResult is the result of a map stats call.
- Metrics
- Metrics are aggregated metrics of a node.
- Network
Error - A failure of the network: connecting, TLS, the connection breaking.
- Node
Result - NodeResult is information about a Centrifugo node.
- Pager
client - The items of a paged method, every page of them, read a page at a
time: what
Client::history_all,Client::device_list_alland the other*_allmethods return. - Payload
Error - A payload which did not encode, or decode as the type asked.
- Pending
client - The outcome of one command of a
Batch, available once the batch is sent. - Presence
Request - PresenceRequest returns the online presence of a channel: all clients currently subscribed to it. Presence must be enabled for the channel.
- Presence
Result - PresenceResult is the result of a presence call.
- Presence
Stats Request - PresenceStatsRequest returns short presence information of a channel: the number of clients and of unique users. Presence must be enabled for the channel.
- Presence
Stats Result - PresenceStatsResult is the result of a presence stats call.
- Process
- Process is resource usage of a node process. Centrifugo PRO only.
- Publication
- Publication is a publication in a channel history.
- Publish
Request - PublishRequest publishes data into a channel.
- Publish
Result - PublishResult is the result of a successful publish.
- Push
Limit Strategy - PushLimitStrategy limits when and how often pushes are sent. Centrifugo PRO only.
- Push
Localization - PushLocalization holds translations for one language/locale. Centrifugo PRO only.
- Push
Notification - PushNotification is a push notification in the format of each provider. Centrifugo PRO only.
- Push
Rate Limit Strategy - PushRateLimitStrategy rate limits pushes per device. Centrifugo PRO only.
- Push
Recipient - PushRecipient describes who receives a push notification. Set only one of its fields. Centrifugo PRO only.
- Push
Time Limit Strategy - PushTimeLimitStrategy sends pushes within a window of the device local time. Centrifugo PRO only.
- Rate
Limit Policy - RateLimitPolicy allows rate pushes per interval_ms. Centrifugo PRO only.
- RawValue
- Reference to a range of bytes encompassing a single valid JSON value in the input data.
- Refresh
Request - RefreshRequest refreshes a user’s connections, mostly useful with unidirectional transports. Without expire_at the connections become non-expiring.
- Refresh
Result - RefreshResult is the result of a refresh call. Empty at the moment.
- Request
Info client - Describes one HTTP request to the API, for
Config::on_request. - Retry
Stopped Error - A broadcast with retries which stopped before its last attempt: its
on_attempt_errorcallback returned an error, or the call’s deadline came while it waited to retry.erroris the broadcast’s error at that point - aError::BroadcastFailedChannelsholding every channel’s outcome when some attempt got a reply. - Revoke
Token Request - RevokeTokenRequest revokes a token by its unique ID (jti claim of a JWT). Clients using the token are disconnected shortly, and can not connect with it again. Centrifugo PRO only.
- Revoke
Token Result - RevokeTokenResult is the result of a revoke token call. Empty at the moment. Centrifugo PRO only.
- Send
Push Notification Request - SendPushNotificationRequest sends a push notification. The request is queued and sent to the provider by Centrifugo workers. Centrifugo PRO only.
- Send
Push Notification Result - SendPushNotificationResult is the result of a send push notification call. Centrifugo PRO only.
- Shared
Poll Publish Request - SharedPollPublishRequest pushes data for a key directly to clients of a shared poll channel, without waiting for the next poll cycle. Requires versioned mode and publish_enabled on the namespace.
- Shared
Poll Publish Result - SharedPollPublishResult is the result of a shared poll publish call. Empty at the moment.
- Stream
Position - StreamPosition is a position in a channel stream.
- Subscribe
Option Override - SubscribeOptionOverride overrides channel options for a server-side subscription. Unset fields keep the value from the channel configuration.
- Subscribe
Request - SubscribeRequest subscribes active sessions of a user to a channel (server-side subscription). It does not create a streaming subscription for the caller.
- Subscribe
Result - SubscribeResult is the result of a subscribe call. Empty at the moment.
- Subscription
Token Info - SubscriptionTokenInfo is information about a subscription token. Centrifugo PRO only.
- Timeout
Error - A call whose deadline passed. After a timeout Centrifugo may still have
carried the request out: retry a publication only with the same
idempotency_key. - Unblock
User Request - UnblockUserRequest unblocks a user. Centrifugo PRO only.
- Unblock
User Result - UnblockUserResult is the result of an unblock user call. Empty at the moment. Centrifugo PRO only.
- Unsubscribe
Request - UnsubscribeRequest unsubscribes a user from a channel.
- Unsubscribe
Result - UnsubscribeResult is the result of an unsubscribe call. Empty at the moment.
- Update
Push Status Request - UpdatePushStatusRequest saves the delivery or interaction status of a push notification to analytics. Experimental. Centrifugo PRO only.
- Update
Push Status Result - UpdatePushStatusResult is the result of an update push status call. Empty at the moment. Centrifugo PRO only.
- Update
User Status Request - UpdateUserStatusRequest marks users as active and online now, and sets their state when one is given. Centrifugo PRO only.
- Update
User Status Result - UpdateUserStatusResult is the result of an update user status call. Empty at the moment. Centrifugo PRO only.
- User
Status - UserStatus is the status of a user. Centrifugo PRO only.
- User
Topic - UserTopic is a topic subscription of a user. Centrifugo PRO only.
- User
Topic Filter - UserTopicFilter selects user topic subscriptions. Centrifugo PRO only.
- User
Topic List Request - UserTopicListRequest returns a paginated list of user topic subscriptions. Centrifugo PRO only.
- User
Topic List Result - UserTopicListResult is the result of a user topic list call. Centrifugo PRO only.
- User
Topic Update Request - UserTopicUpdateRequest changes the topics of a user. The change is also applied to the user’s registered devices. Centrifugo PRO only.
- User
Topic Update Result - UserTopicUpdateResult is the result of a user topic update call. Empty at the moment. Centrifugo PRO only.
- WebPush
Push Notification - WebPushPushNotification is a notification for Web Push. Centrifugo PRO only.
Enums§
- Error
- The error of a call. Every call returns one unless it did everything it
was asked:
?is always correct code. - Retry
client - What
Client::broadcast_with_retrydoes after a failed attempt, as itson_attempt_errorcallback decides.
Constants§
- CMP_CT
"ct", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_EQ
"eq", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_EW
"ew", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_EX
"ex", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_GT
"gt", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_GTE
"gte", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_IN
"in", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_LT
"lt", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_LTE
"lte", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_NEQ
"neq", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_NEX
"nex", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_NIN
"nin", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- CMP_SW
"sw", a value ofcmpofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- FILTER_
NODE_ OP_ AND "and", a value ofopofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- FILTER_
NODE_ OP_ NOT "not", a value ofopofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- FILTER_
NODE_ OP_ OR "or", a value ofopofFilterNode. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- KEY_
MODE_ IF_ EXISTS "if_exists", a value ofkey_modeofMapPublishRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- KEY_
MODE_ IF_ NEW "if_new", a value ofkey_modeofMapPublishRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- OP_ADD
"add", a value ofopofDeviceTopicsUpdate,opofDeviceTopicUpdateRequestandopofUserTopicUpdateRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- OP_
REMOVE "remove", a value ofopofDeviceTopicsUpdate,opofDeviceTopicUpdateRequestandopofUserTopicUpdateRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- OP_SET
"set", a value ofopofDeviceTopicsUpdate,opofDeviceTopicUpdateRequestandopofUserTopicUpdateRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- PLATFORM_
ANDROID "android", a value ofplatformofDeviceRegisterRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- PLATFORM_
IOS "ios", a value ofplatformofDeviceRegisterRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- PLATFORM_
WEB "web", a value ofplatformofDeviceRegisterRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- PROVIDER_
APNS "apns", a value ofproviderofDeviceRegisterRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- PROVIDER_
FCM "fcm", a value ofproviderofDeviceRegisterRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- PROVIDER_
HMS "hms", a value ofproviderofDeviceRegisterRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- PROVIDER_
WEBPUSH "webpush", a value ofproviderofDeviceRegisterRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- STATUS_
DELIVERED "delivered", a value ofstatusofUpdatePushStatusRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.- STATUS_
INTERACTED "interacted", a value ofstatusofUpdatePushStatusRequest. The field is a string: a value Centrifugo accepts which no constant names can still be sent.
Traits§
- Endpoint
Source client - Returns Centrifugo’s base URL per request: see
Config::with_endpoint_fn. A closure returning a future ofResult<String, BoxError>is one. - Http
Client client - Sends the client’s HTTP requests:
DefaultHttpClient, or one of the application’s - to add tracing, to test code using the client without Centrifugo. - Payload
Ext - Decodes a payload into an application type: a publication’s
data, a proxy request’sdata, a presence entry’sconn_info. - Request
- Implemented by the request type of every API method:
PublishRequest,BroadcastRequestand the others. Only the crate’s types implement it. - Token
Source client - Returns the token sent with every request as
Authorization: Bearer, for Centrifugo PRO’s JWKS authentication of the API: seeConfig::bearer_token. A closure returning a future ofResult<String, BoxError>is one, and so istoken::ApiTokenSource.
Functions§
- exponential_
backoff client - Returns the wait before retrying after a failed attempt, with attempt 1
being the first failure:
baseafter it, twice as long after each next one, up tolimit. Each wait is a random time between half of it and all of it, so that clients which failed together - when a broker was down - do not all retry at the same moment. A limit below base counts as base, and an attempt below 1 as 1. - json
- Encodes
valueas a payload, for thedata,infoand other payload fields of requests and proxy results: - retryable
- Reports whether retrying the call which returned
errmay succeed: the error came from a temporary condition, not from the request. - wait
client - Waits for
d, or untildeadline, and returnsError::Timeoutwhen the deadline comes first: the wait between the attempts of a retry loop sharing a deadline. A sleep which ignores the deadline would keep the loop - andClient::close- waiting after it.
Type Aliases§
- BoxError
- A boxed error, as application functions return them: the endpoint and token functions, HTTP clients, handler functions.
- BoxFuture
client - A boxed future, as the traits of the crate return them.
- OnAttempt
Error client - Decides what happens after a failed attempt of
Client::broadcast_with_retry: seeBroadcastRetryOptions::on_attempt_error.