pub struct Client { /* private fields */ }Implementations§
Source§impl Client
impl Client
Sourcepub fn consume_with<H>(
&self,
topic: &str,
options: &ConsumeOptions,
handler: H,
) -> Result<usize, ConsumeError>
pub fn consume_with<H>( &self, topic: &str, options: &ConsumeOptions, handler: H, ) -> Result<usize, ConsumeError>
Reads from the queue and calls handler for each message (see the module). Returns how many were
handled. If handler returns Err, the message is not deleted and the error propagates.
Source§impl Client
impl Client
pub fn new(config: Config) -> Result<Client, Error>
Sourcepub fn with_transport(
config: Config,
transport: Box<dyn Transport>,
sleeper: Arc<dyn Fn(Duration) + Send + Sync>,
) -> Result<Client, Error>
pub fn with_transport( config: Config, transport: Box<dyn Transport>, sleeper: Arc<dyn Fn(Duration) + Send + Sync>, ) -> Result<Client, Error>
To swap the network stack (and, in tests, the wait between attempts).
pub fn config(&self) -> &Config
Sourcepub fn call(&self, call: &Call) -> Result<Reply, Error>
pub fn call(&self, call: &Call) -> Result<Reply, Error>
Makes the call, retrying only what the contract says to retry (section 18.4):
429 and 503 (waiting for the Retry-After, or 1 s, 2 s, 4 s), 502 and 504 only with
retry_gateway, and a network failure before sending. Never a 4xx (except 429), nor
a failure after sending the body, nor a timeout.
Source§impl Client
impl Client
Sourcepub fn create_topic(&self, request: &TopicRequest) -> Result<Topic, Error>
pub fn create_topic(&self, request: &TopicRequest) -> Result<Topic, Error>
POST /topics.
Sourcepub fn list_topics(
&self,
limit: Option<u32>,
cursor: Option<&str>,
name: Option<&str>,
) -> Result<Page<Topic>, Error>
pub fn list_topics( &self, limit: Option<u32>, cursor: Option<&str>, name: Option<&str>, ) -> Result<Page<Topic>, Error>
GET /topics. Parameters that are None do not go in the query.
Sourcepub fn list_all_topics(&self, name: Option<&str>) -> Result<Vec<Topic>, Error>
pub fn list_all_topics(&self, name: Option<&str>) -> Result<Vec<Topic>, Error>
All topics, page by page.
Sourcepub fn update_topic(
&self,
name: &str,
update: &TopicUpdate,
) -> Result<Topic, Error>
pub fn update_topic( &self, name: &str, update: &TopicUpdate, ) -> Result<Topic, Error>
PATCH /topics/{topic}.
Sourcepub fn publish(
&self,
topic: &str,
body: &[u8],
options: &PublishOptions,
) -> Result<PublishResponse, Error>
pub fn publish( &self, topic: &str, body: &[u8], options: &PublishOptions, ) -> Result<PublishResponse, Error>
POST /topics/{topic}/messages. The body goes as bytes, without validation.
pub fn publish_json( &self, topic: &str, json_text: &str, ) -> Result<PublishResponse, Error>
pub fn publish_text( &self, topic: &str, text: &str, ) -> Result<PublishResponse, Error>
Sourcepub fn consume(
&self,
topic: &str,
options: &ConsumeOptions,
) -> Result<Vec<Message>, Error>
pub fn consume( &self, topic: &str, options: &ConsumeOptions, ) -> Result<Vec<Message>, Error>
GET /topics/{topic}/messages. The read time is waitTime + 10 s, not the
requestTimeout.
pub fn consume_call(&self, topic: &str, options: &ConsumeOptions) -> Call
Sourcepub fn ack(
&self,
topic: &str,
message_id: &str,
receipt_token: &str,
) -> Result<(), Error>
pub fn ack( &self, topic: &str, message_id: &str, receipt_token: &str, ) -> Result<(), Error>
DELETE /topics/{topic}/messages/{id}?receiptToken=.
Sourcepub fn change_visibility(
&self,
topic: &str,
message_id: &str,
receipt_token: &str,
seconds: u32,
) -> Result<VisibilityResponse, Error>
pub fn change_visibility( &self, topic: &str, message_id: &str, receipt_token: &str, seconds: u32, ) -> Result<VisibilityResponse, Error>
PUT /topics/{topic}/messages/{id}/visibility?receiptToken=.
Sourcepub fn subscribe<H, S>(
&self,
topic: &str,
options: &ConsumeOptions,
stop: S,
handler: H,
) -> Result<(), Error>
pub fn subscribe<H, S>( &self, topic: &str, options: &ConsumeOptions, stop: S, handler: H, ) -> Result<(), Error>
The consume loop (D71.1): long polling (waitTime 20 and one message at a time, if not
set), calls the handler and acknowledges by itself only if it returns Ok. stop is
checked before each consume and after each message; returning true, the loop ends.
A server error while consuming or acknowledging propagates.