-
Notifications
You must be signed in to change notification settings - Fork 299
Added sdk/storage/azure_storage_queue (#2730) #2732
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements initial support for the 2018-03-28 Queue API in the Azure Storage Queue SDK for Rust. Key changes include the introduction of new client functions for managing queues, a comprehensive test suite covering the new operations, and several example programs and documentation updates.
Reviewed Changes
Copilot reviewed 18 out of 36 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sdk/storage/azure_storage_queue/tsp-location.yaml | Adds configuration metadata for the queue API |
sdk/storage/azure_storage_queue/tests/queue_service_client.rs | Introduces recorded tests for queue service |
sdk/storage/azure_storage_queue/src/lib.rs | Sets up module exports for clients and models |
sdk/storage/azure_storage_queue/src/clients/queue_service_client.rs | Implements QueueServiceClient API functions |
sdk/storage/azure_storage_queue/examples/* | Provides usage examples and helper functions |
sdk/storage/azure_storage_queue/Cargo.toml | Configures the crate with required dependencies and features |
sdk/storage/azure_storage_queue/CHANGELOG.md | Documents the initial supported release |
sdk/storage/assets.json | Updates asset references |
sdk/storage/.dict.txt | Updates custom dictionary with new terms |
Cargo.toml | Adds the queue SDK to the workspace members |
Comments suppressed due to low confidence (1)
sdk/storage/azure_storage_queue/src/clients/queue_service_client.rs:90
- The documentation for the 'queue_name' parameter in the delete_queue function incorrectly states that it is 'to create' the queue. Please update the description to indicate that it is the name of the queue to delete.
/// * `queue_name` - The name of the queue to create
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
1833dda
to
114ff2e
Compare
sdk/storage/azure_storage_queue/src/clients/queue_service_client.rs
Outdated
Show resolved
Hide resolved
2a7798a
to
334d48f
Compare
439ef72
to
fbc34b4
Compare
sdk/storage/azure_storage_queue/src/clients/queue_service_client.rs
Outdated
Show resolved
Hide resolved
Fixes #2708 Added support for the 2018-03-28 Queue API. The following functions have been created on the new QueueClient, roughly following the pattern in the .Net SDK: queue_client: new create create_if_not_exists clear delete delete_if_exists delete_message exists get_metadata get_properties enqueue_message dequeue_message dequeue_messages peek_message peek_messages set_metadata update_message get_access_policy set_access_policy queue_service_client: new create_queue delete_queue get_properties set_properties list_queues_segment (paginated) Examples of how to use each method has been provided in the ~/sdk/storage/examples/queue_client.rs file. Recorded tests has also been pushed to the repo Azure/azure-sdk-assets and the assets.json updated. The client is generated using tsp-client using remote Azure/azure-rest-api-specs repo.
* Regenerated client based on new TSP * Switching set and get metadata to use the generated client. * Added get_statistics * Updated samples to show how to pass realistic parameters.
…json for the queue crate. Removing access policy api as there is issue with (de)serialization and this is also not yet implemented in blob.
- Updated change logs to mention unreleased - Removed all functions list from the README.md - Renaming examples to samples to match pattern in other languages - Removed singular helper functions and exists helper functions - Adjusting code based on update to the dependencies - Changed StorageServiceProperties to QueueServiceProperties - Exposing clients and client options from the crate root - Update test names to reflect operation
…argument in the method directly rather than in the option bag.
…ceStats`. Updated `QueueClient::send_message` to return `Result<Response<SentMessage, XmlFormat>>` in place of `Result<Response<Option<SentMessage>, XmlFormat>>`
58c5800
to
06f0ab4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most nits/questions, but there is one blocker. After that, doesn't have to be perfect, but I'd like to see some tracking issues opened for other work like missing docs, fixing up the dead_code
, etc.
# Azure Queue client library for Rust | ||
|
||
Azure Queue Storage is a service for storing large numbers of messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: some disagreement on branding here. Is it "Azure Queue" or "Azure Queue Storage"? I thought it was actually "Azure Storage Queue".
# Manual example definitions pointing to samples/ directory | ||
[[example]] | ||
name = "queue_client" | ||
path = "samples/queue_client.rs" | ||
|
||
[[example]] | ||
name = "queue_service_client" | ||
path = "samples/queue_service_client.rs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not idiomatic. Put them in the "examples/" directory and get rid of these entries. It's just extra maintenance for no reason.
|
||
[features] | ||
default = ["reqwest"] | ||
reqwest = ["dep:reqwest"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you taking a direct dependency on reqwest
? This is highly sus. So long as you're HTTP-based, you must use the types in azure_core
only so that we have consistent HTTP client override support across all HTTP-based crates: same as any other Azure SDK language.
blocker
/// A client to interact with a specific Azure storage queue, although that queue may not yet exist. | ||
pub struct QueueClient { | ||
pub(super) endpoint: Url, | ||
pub(super) client: GeneratedQueueClient, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is wrapping the generated client necessary? I know why Blob is doing it - to "smooth" out the DX - but is that true for Queue as well? Ideally, we're just generating.
#![allow(dead_code)] | ||
#![allow(unused_imports)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are code smells in a lib crate. If you have some code that is surfacing as public in the lib crate or unused imports, you need to fix them. dead_code
indicates something isn't used and isn't public. If this is model types, then add #[allow(dead_code)]
to that module. Don't do a whole-lib suppression.
#[expect(deprecated, reason = "requires emitter update")] | ||
mod generated; | ||
|
||
pub mod models { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Public modules must be documented.
mod clients; | ||
pub use crate::clients::QueueClient; | ||
pub use crate::clients::QueueServiceClient; | ||
pub use crate::generated::clients::{QueueClientOptions, QueueServiceClientOptions}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guidelines are that you must make this public and then expose your wrapped clients from there. Instead, do something like:
mod clients; | |
pub use crate::clients::QueueClient; | |
pub use crate::clients::QueueServiceClient; | |
pub use crate::generated::clients::{QueueClientOptions, QueueServiceClientOptions}; | |
//! Necessary documentation | |
pub mod clients; |
Thern in clients/mod.rs
, just define the types as pub struct
and re-export the queue service client from there.
/// Returns an error if the queue doesn't exist or if the request fails | ||
pub async fn set_metadata( | ||
&self, | ||
metadata: HashMap<String, String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Body parameters - if this is a body parameter - must be RequestContent<T>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This raises the question of who these samples are for. Are they full-blown EXEs customers can use - like what Cosmos has - or more for copy and pastability? If the latter, a bunch of helpers not within a single source isn't going to be very useful.
Fixes #2708
Added support for the 2018-03-28 Queue API. The following functions have been created on the new QueueClient, roughly following the pattern in the .Net SDK:
QueueServiceClient
The
QueueServiceClient
provides operations to interact with the Azure Storage Queue service at the account level.new
endpoint: &str
credential: Arc<dyn TokenCredential>
options: Option<QueueServiceClientOptions>
Result<Self>
endpoint
&self
&Url
queue_client
&self
queue_name: String
QueueClient
create_queue
&self
queue_name: &str
options: Option<QueueClientCreateOptions<'_>>
Result<Response<(), NoFormat>>
delete_queue
&self
queue_name: &str
options: Option<QueueClientDeleteOptions<'_>>
Result<Response<(), NoFormat>>
get_properties
&self
options: Option<QueueServiceClientGetPropertiesOptions<'_>>
Result<Response<StorageServiceProperties, XmlFormat>>
set_properties
&self
storage_service_properties: RequestContent<StorageServiceProperties>
options: Option<QueueServiceClientSetPropertiesOptions<'_>>
Result<Response<(), NoFormat>>
list_queues_segment
&self
options: Option<QueueServiceClientListQueuesSegmentOptions<'_>>
Result<PageIterator<Response<ListQueuesSegmentResponse, XmlFormat>>>
get_statistics
&self
options: Option<QueueServiceClientGetStatisticsOptions<'_>>
Result<Response<StorageServiceStats, XmlFormat>>
QueueClient
The
QueueClient
provides operations to interact with a specific Azure Storage Queue.new
endpoint: &str
queue_name: &str
credential: Arc<dyn TokenCredential>
options: Option<QueueClientOptions>
Result<Self>
endpoint
&self
&Url
queue_name
&self
&str
Queue Management
create
&self
options: Option<QueueClientCreateOptions<'_>>
Result<Response<(), NoFormat>>
delete
&self
options: Option<QueueClientDeleteOptions<'_>>
Result<Response<(), NoFormat>>
exists
&self
Result<bool>
clear
&self
options: Option<QueueClientClearOptions<'_>>
Result<Response<(), NoFormat>>
Metadata Operations
set_metadata
&self
options: Option<QueueClientSetMetadataOptions<'_>>
Result<Response<(), NoFormat>>
get_metadata
&self
options: Option<QueueClientGetMetadataOptions<'_>>
Result<Response<QueueClientGetMetadataResult, NoFormat>>
Message Operations
send_message
&self
queue_message: RequestContent<QueueMessage>
options: Option<QueueClientSendMessageOptions<'_>>
Result<Response<Option<SentMessage>, XmlFormat>>
receive_messages
&self
options: Option<QueueClientReceiveMessagesOptions<'_>>
Result<Response<ListOfReceivedMessage, XmlFormat>>
peek_messages
&self
options: Option<QueueClientPeekOptions<'_>>
Result<Response<ListOfPeekedMessage, XmlFormat>>
delete_message
&self
message_id: &str
pop_receipt: &str
options: Option<QueueClientDeleteMessageOptions<'_>>
Result<Response<(), NoFormat>>
update_message
&self
message_id: &str
pop_receipt: &str
visibility_timeout: i32
options: Option<QueueClientUpdateOptions<'_>>
Result<Response<(), NoFormat>>
Access Policy Operations
get_access_policy
&self
options: Option<QueueClientGetAccessPolicyOptions<'_>>
Result<Response<ListOfSignedIdentifier, XmlFormat>>
set_access_policy
&self
queue_acl: RequestContent<ListOfSignedIdentifier>
options: Option<QueueClientSetAccessPolicyOptions<'_>>
Result<Response<QueueClientSetAccessPolicyResult, NoFormat>>
Examples of how to use each method has been provided in the
sdk/storage/examples/queue_client.rs
file.Recorded tests has also been pushed to the repo
Azure/azure-sdk-assets
and theassets.json
updated.The client is generated using tsp-client using remote
Azure/azure-rest-api-specs
repo.