Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename lock_expiry to timeout #1651

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sdk/messaging_servicebus/src/service_bus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ async fn peek_lock_message(
queue_or_topic: &str,
policy_name: &str,
signing_key: &Secret,
lock_expiry: Option<Duration>,
timeout: Option<Duration>,
subscription: Option<&str>,
) -> azure_core::Result<CollectedResponse> {
let url = craft_peek_lock_url(namespace, queue_or_topic, lock_expiry, subscription)?;
let url = craft_peek_lock_url(namespace, queue_or_topic, timeout, subscription)?;

let req = finalize_request(url.as_ref(), Method::Post, None, policy_name, signing_key)?;

Expand All @@ -162,10 +162,10 @@ async fn peek_lock_message2(
queue_or_topic: &str,
policy_name: &str,
signing_key: &Secret,
lock_expiry: Option<Duration>,
timeout: Option<Duration>,
subscription: Option<&str>,
) -> azure_core::Result<PeekLockResponse> {
let url = craft_peek_lock_url(namespace, queue_or_topic, lock_expiry, subscription)?;
let url = craft_peek_lock_url(namespace, queue_or_topic, timeout, subscription)?;

let req = finalize_request(url.as_ref(), Method::Post, None, policy_name, signing_key)?;

Expand Down
10 changes: 8 additions & 2 deletions sdk/messaging_servicebus/src/service_bus/queue_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,24 @@ impl QueueClient {

/// Non-destructively read a message
///
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
/// If no message is received within this time, an empty 204 HTTP response will be returned.
///
/// Note: This function does not return the delete location
/// of the message, so, after reading, you will lose
/// "track" of it until the lock expiry runs out and
/// the message can be consumed by others. If you want to keep
/// track of this message (i.e., have the possibility of deletion),
/// use `peek_lock_message2`.
pub async fn peek_lock_message(&self, lock_expiry: Option<Duration>) -> Result<String, Error> {
pub async fn peek_lock_message(&self, timeout: Option<Duration>) -> Result<String, Error> {
body_bytes_to_utf8(
peek_lock_message(
&self.http_client,
&self.namespace,
&self.queue,
&self.policy_name,
&self.signing_key,
lock_expiry,
timeout,
None,
)
.await?
Expand All @@ -103,6 +106,9 @@ impl QueueClient {

/// Non-destructively read a message but track it
///
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
/// If no message is received within this time, an empty 204 HTTP response will be returned.
///
/// Note: This function returns a `PeekLockResponse`
/// that contains a helper `delete_message` function.
pub async fn peek_lock_message2(
Expand Down
10 changes: 8 additions & 2 deletions sdk/messaging_servicebus/src/service_bus/topic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,24 @@ impl SubscriptionReceiver {

/// Non-destructively read a message
///
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
/// If no message is received within this time, an empty 204 HTTP response will be returned.
///
/// Note: This function does not return the delete location
/// of the message, so, after reading, you will lose
/// "track" of it until the lock expiry runs out and
/// the message can be consumed by others. If you want to keep
/// track of this message (i.e., have the possibility of deletion),
/// use `peek_lock_message2`.
pub async fn peek_lock_message(&self, lock_expiry: Option<Duration>) -> Result<String, Error> {
pub async fn peek_lock_message(&self, timeout: Option<Duration>) -> Result<String, Error> {
body_bytes_to_utf8(
peek_lock_message(
&self.topic_client.http_client,
&self.topic_client.namespace,
&self.topic_client.topic,
&self.topic_client.policy_name,
&self.topic_client.signing_key,
lock_expiry,
timeout,
Some(&self.subscription),
)
.await?
Expand All @@ -139,6 +142,9 @@ impl SubscriptionReceiver {

/// Non-destructively read a message but track it
///
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
/// If no message is received within this time, an empty 204 HTTP response will be returned.
///
/// Note: This function returns a `PeekLockResponse`
/// that contains a helper `delete_message` function.
pub async fn peek_lock_message2(
Expand Down
4 changes: 2 additions & 2 deletions sdk/messaging_servicebus/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::time::Duration;
pub fn craft_peek_lock_url(
namespace: &str,
queue_or_topic: &str,
lock_expiry: Option<Duration>,
timeout: Option<Duration>,
subscription: Option<&str>,
) -> Result<Url, Error> {
let url_path = get_head_url(namespace, queue_or_topic, subscription);
Expand All @@ -17,7 +17,7 @@ pub fn craft_peek_lock_url(
)?;

// add timeout, if given
if let Some(t) = lock_expiry {
if let Some(t) = timeout {
url.query_pairs_mut()
.append_pair("timeout", &t.as_secs().to_string());
};
Expand Down
Loading