Skip to content

Commit 7ac895a

Browse files
Gaelik-gitBaptiste LE MORLEC
andauthored
Rename lock_expiry to timeout (#1651)
Co-authored-by: Baptiste LE MORLEC <[email protected]>
1 parent fd7caa3 commit 7ac895a

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

sdk/messaging_servicebus/src/service_bus/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ async fn peek_lock_message(
139139
queue_or_topic: &str,
140140
policy_name: &str,
141141
signing_key: &Secret,
142-
lock_expiry: Option<Duration>,
142+
timeout: Option<Duration>,
143143
subscription: Option<&str>,
144144
) -> azure_core::Result<CollectedResponse> {
145-
let url = craft_peek_lock_url(namespace, queue_or_topic, lock_expiry, subscription)?;
145+
let url = craft_peek_lock_url(namespace, queue_or_topic, timeout, subscription)?;
146146

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

@@ -162,10 +162,10 @@ async fn peek_lock_message2(
162162
queue_or_topic: &str,
163163
policy_name: &str,
164164
signing_key: &Secret,
165-
lock_expiry: Option<Duration>,
165+
timeout: Option<Duration>,
166166
subscription: Option<&str>,
167167
) -> azure_core::Result<PeekLockResponse> {
168-
let url = craft_peek_lock_url(namespace, queue_or_topic, lock_expiry, subscription)?;
168+
let url = craft_peek_lock_url(namespace, queue_or_topic, timeout, subscription)?;
169169

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

sdk/messaging_servicebus/src/service_bus/queue_client.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,24 @@ impl QueueClient {
7979

8080
/// Non-destructively read a message
8181
///
82+
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
83+
/// If no message is received within this time, an empty 204 HTTP response will be returned.
84+
///
8285
/// Note: This function does not return the delete location
8386
/// of the message, so, after reading, you will lose
8487
/// "track" of it until the lock expiry runs out and
8588
/// the message can be consumed by others. If you want to keep
8689
/// track of this message (i.e., have the possibility of deletion),
8790
/// use `peek_lock_message2`.
88-
pub async fn peek_lock_message(&self, lock_expiry: Option<Duration>) -> Result<String, Error> {
91+
pub async fn peek_lock_message(&self, timeout: Option<Duration>) -> Result<String, Error> {
8992
body_bytes_to_utf8(
9093
peek_lock_message(
9194
&self.http_client,
9295
&self.namespace,
9396
&self.queue,
9497
&self.policy_name,
9598
&self.signing_key,
96-
lock_expiry,
99+
timeout,
97100
None,
98101
)
99102
.await?
@@ -103,6 +106,9 @@ impl QueueClient {
103106

104107
/// Non-destructively read a message but track it
105108
///
109+
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
110+
/// If no message is received within this time, an empty 204 HTTP response will be returned.
111+
///
106112
/// Note: This function returns a `PeekLockResponse`
107113
/// that contains a helper `delete_message` function.
108114
pub async fn peek_lock_message2(

sdk/messaging_servicebus/src/service_bus/topic_client.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,24 @@ impl SubscriptionReceiver {
115115

116116
/// Non-destructively read a message
117117
///
118+
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
119+
/// If no message is received within this time, an empty 204 HTTP response will be returned.
120+
///
118121
/// Note: This function does not return the delete location
119122
/// of the message, so, after reading, you will lose
120123
/// "track" of it until the lock expiry runs out and
121124
/// the message can be consumed by others. If you want to keep
122125
/// track of this message (i.e., have the possibility of deletion),
123126
/// use `peek_lock_message2`.
124-
pub async fn peek_lock_message(&self, lock_expiry: Option<Duration>) -> Result<String, Error> {
127+
pub async fn peek_lock_message(&self, timeout: Option<Duration>) -> Result<String, Error> {
125128
body_bytes_to_utf8(
126129
peek_lock_message(
127130
&self.topic_client.http_client,
128131
&self.topic_client.namespace,
129132
&self.topic_client.topic,
130133
&self.topic_client.policy_name,
131134
&self.topic_client.signing_key,
132-
lock_expiry,
135+
timeout,
133136
Some(&self.subscription),
134137
)
135138
.await?
@@ -139,6 +142,9 @@ impl SubscriptionReceiver {
139142

140143
/// Non-destructively read a message but track it
141144
///
145+
/// * `timeout` : Sets the maximum duration for the HTTP connection when receiving a message.
146+
/// If no message is received within this time, an empty 204 HTTP response will be returned.
147+
///
142148
/// Note: This function returns a `PeekLockResponse`
143149
/// that contains a helper `delete_message` function.
144150
pub async fn peek_lock_message2(

sdk/messaging_servicebus/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::time::Duration;
77
pub fn craft_peek_lock_url(
88
namespace: &str,
99
queue_or_topic: &str,
10-
lock_expiry: Option<Duration>,
10+
timeout: Option<Duration>,
1111
subscription: Option<&str>,
1212
) -> Result<Url, Error> {
1313
let url_path = get_head_url(namespace, queue_or_topic, subscription);
@@ -17,7 +17,7 @@ pub fn craft_peek_lock_url(
1717
)?;
1818

1919
// add timeout, if given
20-
if let Some(t) = lock_expiry {
20+
if let Some(t) = timeout {
2121
url.query_pairs_mut()
2222
.append_pair("timeout", &t.as_secs().to_string());
2323
};

0 commit comments

Comments
 (0)